Checking if you are on a category AND a specific page ID / page name
-
Hi,
I have an if statement checking that a certain category exists and if it does, to add an additional button to that page. There are three pages where this needs to happen and they are all working fine. There is another page on the site which also makes use of one of the categories called news and here too the buttons are being displayed which is not what I want.
My solution would be to check first if the category exists, if it does, then add the button. Then I would add another statement to check if I am on a certain page/ID and exclude it from that page.
I have tried a number of options but my inexperience of WP fails me and I am hoping someone might be able to show me how it is done. Here’s a snippet of the code.function add_below_the_post () { $category = get_the_category(); $category = $category[0]->category_nicename; if (!is_wp_error($category)) { if ($category == 'student-stories') { echo('<a class="postFootLink" href="' .site_url() .'/people/student-stories/">Return to ' .$category .'</a>'); } else if ($category == 'news' & $postID == '16') //this is where I am going wrong { echo('<a class="postFootLink" href="' .site_url() .'/news/">Return to ' .$category .'</a>'); } else if ($category == 'research') { echo('<a class="postFootLink" href="' .site_url() .'/research/research-snippet/">Return to ' .$category .' snippets</a>'); } } } add_action('thematic_belowpost', 'add_below_the_post');
Many thanks!
- The topic ‘Checking if you are on a category AND a specific page ID / page name’ is closed to new replies.