805 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
+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
  • 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 ?

805 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
+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
  • 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?

805 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
+5 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.

2468 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+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
}
163 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') )  
805 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
+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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by