bficker
Member
Posted 6 months ago #
Hey,
I'm trying to get specific links to show up only the home page, or only on pages/posts tagged with specific terms. So far the plugin works great, but on my home page (display latest blog posts) it is showing the widget for the home page AND the widget for whatever the latest post is.
Any ideas on how to just display the home page widget?
BTW I have the catagories widget to be set on the home page only for testing. The Phoenix Resources widget is specific for the tag 'phoenix'
alanft
Member
Posted 6 months ago #
what's the logic for the other widget?
if it's something like 'has_tag(x)', then that will be true on the home page if the first (or last) post on the page has that tag. if the idea is to only show the widget on a single post that has tag x use is_single() && has_tag(x)
bficker
Member
Posted 6 months ago #
it is 'has_tag('phoenix'). If I add the is_single() part, then it wouldn't show up on my archive pages right? Which I guess wouldn't be that big of a deal...
bficker
Member
Posted 6 months ago #
So I had to change the is_single() to is_singular() && has_tag(x). Now the widget will not show up on the home page, but will show up on any post or page tagged with x. Thanks for your help!!!
alanft
Member
Posted 6 months ago #
If it works, great, but i wouldn't trust the behaviour of is_singular to do what you want. (check http://codex.wordpress.org/Function_Reference/is_singular )
if what you want is single posts with that tag, or the tag archive page, then you should use
(is_single() && has_tag(x)) || is_tag(x)
which will be true if it's a single post tagged with x, or if you are showing tag x's archive page