我'm creating a slider for my Wordpress theme and I want to create some options on the admin interface to filter posts by category, tag, random or most recent. I'也在使用: <?php echo get_option('category_name'); ?>
开发主题's options page based on a tutorial as well and to call these options I'm . 那么现在我要在滑块上显示帖子的相关代码是什么'm trying to do with this code I just referred is to create some filter options in order to change the posts displayed on the Slider on the Admin interface. Here'
<?php
$carouselPosts = new WP_Query();
$carouselPosts->query('showposts=12');
?>
<?php while ($carouselPosts->have_posts()) : $carouselPosts->the_post(); ?>
以下是我创建主题管理选项页面的方法:
<p><strong>Display by category, write the category name:</strong>
<input type="text" name="category_name" size="45" value="<?php echo get_option('category_name'); ?>" />
</p>
现在,我不太了解php,我真的不知道,我知道这不是正确的方法,但我想要做的是创建这样的东西:
$carouselPosts->query('category_name=<?php echo get_option('category_name'); ?>&showposts=12');
正如我所说,我知道这不是正确的方法,但如果有帮助的话,这是解释滑块教程链接的简单方法:Tutorial Link
1 回答
实际上,它非常接近 . 使用:
只有在尝试将PHP插入HTML时才使用
<?php ?>
. 否则,您可以按原样使用PHP .