1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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
  • 5 Years of Membership
  • Affiliate Level 5
  • Author Level 9
  • Bundle Boss
+8 more
duotive
says

elseif ?

1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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
  • 5 Years of Membership
  • Affiliate Level 5
  • Author Level 9
  • Bundle Boss
+8 more
duotive
says

using query_posts?

1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 more
Gareth_Gillman
says

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

3007 posts
  • 5 Years of Membership
  • Affiliate Level 5
  • Author Level 9
  • Bundle Boss
+8 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.

2468 posts
  • 6 Years of Membership
  • Author Level 2
  • Affiliate Level 4
  • Beta Tester
+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
}
179 posts
  • Author Level 10
  • Collector Level 4
  • Top Monthly Author
  • Trendsetter
+6 more
MNKY
says
Maybe something like:
  if ( has_tag('one') || has_tag('two') || has_tag('three') )  
1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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