Here’s what I’ve got so far (that isn’t working):
<?php
$title = get_the_title();
if(has_tag($title) && in_category(array('10','12','21','22'))){
?>
Content here
<?php } else {} endwhile; endif; ?>
Please help! Thank you
]]>I don’t know php but am able to get things working by trying.
So i use this piece of code
<?php if (has_tag(‘wrapping-paper’)) { ?>
<FONT color=”red” size=3><B>
Text
</B></FONT>
<?php } ?>
to put text on the screen if the tag is used but now i would like to do the opposite show text if this tag is not used.
How can i do that?
Greetings,
George
If someone can help me. i want the $tg variable get the tag that was found. Sorry for my bad english
[closed as duplicate: https://www.ads-software.com/support/topic/has_tag-help-1?replies=3 ]
]]>I’m working on a theme using different thumbnail sizes on blog homepage. My code was working fine before the update. And now… It looks like the condition if(is_home() && has_tag(array(‘place1’, ‘place2’, ‘place5’))) does not work anymore… When I remove the is_home() part, it works fine. But I need it… Here is the code.
1st try, working fine before WP 3.3 :
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class='thumbnail-image'>
<a href='<?php the_permalink() ?>'>
<?php
if(is_home() && has_tag(array('place1', 'place2', 'place5'))) {
the_post_thumbnail('home-smallpost-thumbnail');
}
else{
the_post_thumbnail('home-bigpost-thumbnail');
}
?>
</a>
</div>
...
2nd try was this :
if(is_home()) {
if(has_tag(array('emplacement1', 'emplacement2', 'emplacement5'))) {
the_post_thumbnail('home-smallpost-thumbnail');
}
}
3rd try was the same, without the if(is_home()){} part (so only the has_tag() part) and it works fine…
I’m completely lost. Why should the is_home() condition break ? Did you experience this kind of problem lately ? Do you see any explaination ?
I hope to hear from someone soon !
]]>I can query the custom post type, but I can’t figure out how to separate the posts with tags from the posts without.
If(has_tag) isn’t working. It just gives me zero results. If(!has_tag) shows me all of the custom posts regardless of whether they have a tag or not.
How do I build a query to find only the custom posts that contain a tag?
]]>[Code moderated as per the Forum Rules. Please use the pastebin]
I am using the SemiLogic Theme and put that code in a widget but it showed on all pages and posts. If were just all posts it would have been better but I am hoping that with the right use of the has_tag I will be able to call it for specific posts.
Thanks
]]>If I use a has_tag condition on my loop, will the loop go through posts until it finds something with that tag, or will it quit looking after so many posts?
On my loop-index.php, I want to display articles tagged “featured-article”, so I’ve used this condition just after I start my loop:
<?php if ( has_tag('featured-article') ) : ?>
It worked pretty well until someone went through and added a bunch of other posts without using that tag in them.
You can see my loop-index displaying an article with that tag, but not until eleven pages along: https://dev.renacademy.org/charter-school/page/11/
I’ve tried going through the documentation and maybe I’ve missed something, but as far as I can tell, we should expect the loop to keep looking for that tag until it has enough posts for that page.
By the way, I did notice a sticky post feature that probably would work as well for what we’re trying to do in this instance, but we’ll probably want to add other tag-conditioned loops to our index later, so I’d appreciate any ideas you have.
Thanks in advance,
-Velda
]]>