leeyha
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Dislaying Title of Two Category After SearchHi, thanks for this. It comes close to what I wanted & found my solution from this hint you provide.
Thanks Very Much & Merry Xmas.
Here is my solution.
The string that I am passing is actually:
https://website/?s=&cat=3&cat=12Here is my code:
$cats = explode(‘=’, $_SERVER[‘QUERY_STRING’]);
echo $_SERVER[‘QUERY_STRING’]. ‘ is server query | ‘;
echo count($cats). ‘ is count | ‘;
echo $cats[0]. ‘ is 0 | ‘;
echo $cats[1]. ‘ is 1 | ‘;
echo $cats[2]. ‘ is 2 | ‘;
echo $cats[3]. ‘ is 3 | ‘;
if (count($cats) > 2) :
echo get_the_category_by_id($cats[2]). ‘ and ‘. get_the_category_by_id($cats[3]). ‘ categories.’;
else :
echo get_the_category_by_id($cats[1]). ‘ category.’;
endif;
?>Here is my output:
s=&cat=3&cat=12 is server query | 4 is count | s is 0 | &cat is 1 | 3&cat is 2 | 12 is 3 | All Learning Providers and All Locations categories.I know it is not ‘neat’ to pass a string like ‘3&cat’ to get_the_category_by_id() function, but this this case, WordPress is smart enough to pick up the cat_id. I am really pleasantly surprised by this.
Thanks Again.
Forum: Fixing WordPress
In reply to: Dislaying Title of Two Category After SearchThink I wasn’t clear on the help required. The help question is: How can I display the title of the two categories selected on the post page?
Forum: Themes and Templates
In reply to: Include posts with two specific categories on a pageKafkaesqui,
I am looking for something like these codes you provided. Now I am think how do I:
1. Let the use select 2 categories on the sidebar;
2. Pass the selection to these codes in index.php?Please enlighten me. Thanks