576 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
Gareth_Gillman says

Creating a new theme, and come across an issue which should be simple to fix but can’t work it out.

Basically I need to stack the statements, not join them up e.g.

statement 1 Statement 2 Statement 3 Statement 4

Each statement would be different, generating the contents differently hence why they need to be stacked.

The first statement works fine, but the following 3 statements aren’t working, my code currently looks like:

if(has_tags('hot')) {
}
if(has_tags('cold')) {
}
if(has_tags('medium')) {
}
if(has_tags('freezing')) {
}

I know it’s going to be something simple but I can’t find the answer

Any help appreciated

3007 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+7 more
duotive says

elseif ?

576 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
Gareth_Gillman says

elseif doesn’t work because it will only display the first statement, I need to display all the statements at once, as they are basically grabbing 4 articles which are tagged in each category.

3007 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+7 more
duotive says

using query_posts?

576 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
Gareth_Gillman says

yea looks like I will be going down that route, thanks

3007 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+7 more
duotive says

that was the main idea. do not use query_posts, it may result in strange results. use wp_query class ( it does not change global variables as query_posts does) . glad i could give you an idea.

2445 posts
  • Has referred 100+ members
  • Has sold $100+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
digitalimpact says

Not sure how has_tags() works for you, since the function is called has_tag().

Also, not sure I understood what you’re trying to achieve, but has_tag() must be in the loop, as it needs the returned post’s ID to work.

So, something like this can’t work:


if (has_tag('tagname')) { 
// loop here
}
154 posts
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Had an item featured on Envato Market
+4 more
MNKY says
Maybe something like:
  if ( has_tag('one') || has_tag('two') || has_tag('three') )  
576 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
Gareth_Gillman says

Thanks for the replies but solved it with query_posts for now

@ DI – Basically I need to list 4 separate posts, each category will have 4 posts which will be tagged with a different tag, basically showing the best deals from that category

You can view what I mean here

@ Minky – As above, that method won’t work as I need them in separate boxes, each different (see my link to see what I mean).

I have fixed it now with query posts but if there is a better method, I would implement it.

by
by
by
by
by
by