Hi,
I am trying to add a url link on certain pages with a certain category but exclude it from other pages who might have that category but is of a certain page name or even using a certain template page.
I've tried many many different options and asked for help with this on the WP forums too but this leaves me to believe it's not working because I am using Thematic.
Please see this snippet of code and what I am trying to sort out relating to the category "News".
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')
{
if (is_page_template('template-page-news.php'))
{
echo('WORKING'); //here is where I want to exclude the link if it's using a certain template
} else
{
echo('<a class="postFootLink" href="' .site_url() .'/news/news-events/">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');
There is a section in the code above where you will see I am trying to exclude the link but replaced it with a string called 'WORKING' just to test it.
I have tried everything from is_page(16); is_page('news_events') to is_page_template('template-page-news.php'). I have also tried this...
else if ($category == 'news' && !is_page('news-events'))
{
echo('<a class="postFootLink" href="' .site_url() .'/news/news-events/">Return to ' .$category .'</a>');
}
which doesn't work either. I'd really appreciate some insight into this please.
Thanks ;)