554 posts
  • Bought between 10 and 49 items
  • Envato Studio (Microlancer) Beta Tester
  • Exclusive Author
  • Football Contest Participant/Runner-up
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • United Kingdom
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
  • Author had a File in an Envato Bundle
  • Bought between 1 and 9 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 200 and 499 users
+2 more
duotive says

elseif ?

554 posts
  • Bought between 10 and 49 items
  • Envato Studio (Microlancer) Beta Tester
  • Exclusive Author
  • Football Contest Participant/Runner-up
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • United Kingdom
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
  • Author had a File in an Envato Bundle
  • Bought between 1 and 9 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 200 and 499 users
+2 more
duotive says

using query_posts?

554 posts
  • Bought between 10 and 49 items
  • Envato Studio (Microlancer) Beta Tester
  • Exclusive Author
  • Football Contest Participant/Runner-up
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • United Kingdom
Gareth_Gillman says

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

3007 posts
  • Author had a File in an Envato Bundle
  • Bought between 1 and 9 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 200 and 499 users
+2 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.

2444 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Bought between 100 and 499 items
  • Has been a member for 3-4 years
  • Exclusive Author
  • Europe
MNKY says
Maybe something like:
  if ( has_tag('one') || has_tag('two') || has_tag('three') )  
554 posts
  • Bought between 10 and 49 items
  • Envato Studio (Microlancer) Beta Tester
  • Exclusive Author
  • Football Contest Participant/Runner-up
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • United Kingdom
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