开发者

Sorting Featured Posts (Wordpress)

开发者 https://www.devze.com 2022-12-18 12:25 出处:网络
I can display posts from featured category like so: query_posts(\'tag=featured\'); ... but is it possible to further sort it using a dropdown/select menu:

I can display posts from featured category like so:

query_posts('tag=featured');

... but is it possible to further sort it using a dropdown/select menu:

<select name="">
  <option value="reviews">Reviews</option>
  <option value="articles">Articles<开发者_Python百科;/option>
  <option value="interviews">Interviews</option>
</select>

... so when one of the option is selected, how do I modify the original query (which would be now: query_posts('tag=featured+option');) posted above to show the matching posts?

Thanks


query_posts('tag=featured,reviews');

So something like (you need to sanitize this)

$tags = array('featured', $_POST['selectbox']);
$query_posts_string = 'tag=' . join(',', $tags);
query_posts($query_posts_string);
0

精彩评论

暂无评论...
验证码 换一张
取 消