2011-12-17 52 views
0

我对PHP相当陌生,但有一个普遍的理解,但我不知道如何去做这件事。我正在开发一个WordPress主题,并添加了wptheming.com的“选项框架”。我在主页上有一个滑块,它从某个类别获取它的帖子,在这种情况下是类别ID 1.但滑块编码的方式意味着我不能从选项框架中放置代码,这允许用户选择一个类别,到类别ID硬编码的滑块代码中。我以某种方式试图找到合并这两者的方法。下面是代码:WordPress的主题设计:把PHP放在(“”)

这是决定该类别中的滑块部分:

<?php 
$featuredPosts = new WP_Query(); 
$featuredPosts->query("showposts=4&cat=1"); 
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); 
?> 

而且这里的代码行(它返回一个数字),我需要以某种方式进入“ &猫= 1" 的代码前面的块的一部分:

<?php echo of_get_option('slider_cat_number', 'no entry'); ?> 

这似乎是有点愚蠢的问题,但我真的难倒如何去这个!

谢谢, 詹姆斯

+0

尝试http://wordpress.stackexchange.com在未来 – 2011-12-17 00:15:21

+0

是的,我不知道在哪里发布此,所以谢谢。 – iJamesPine 2011-12-17 00:29:35

回答

1

IF(!)我理解正确的问题和IF第二功能之前首先运行。

$x = of_get_option('slider_cat_number', 'no entry'); 
$featuredPosts = new WP_Query(); 
$featuredPosts->query("showposts=4&cat=$x"); 
    while ($featuredPosts->have_posts()) : $featuredPosts->the_post();