• Hello, I’d like to do a thing based on whether or not something is in an event category. This isn’t working.

    Help?

    
    if(has_term( 8, 'term_id' )) { 
    		    $hidetitle = " no-title";
    		} else {
    		    $hideexcerpt = "";
    		}
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hi,

    sorry but can I know where are you trying to use the above snippet?

    Thread Starter joefedorowicz

    (@joefedorowicz)

    As a conditional to do some stuff. That appears on my front page within a query.

    I just would like to know what the best way to check against a term (specifically a category) is?

    The event category is saved within the EM_Event Object, so you cannot retrieve is with a simple “get_term()”.

    You will first have to get into the correct Object.

    Please post your full query so we can look what exactly needs be altered. A very small part is just not clear enough ??

    Also, please provide a link to the front page you are speaking of. It really helps.

    Thread Starter joefedorowicz

    (@joefedorowicz)

    Relevant part bolded

    	while ( $loop->have_posts() ) : $loop->the_post();
    
    		$thumb_id = get_post_thumbnail_id();
    		$hello = get_post_meta($post->ID, 'event_id', true);
    		$thumb_url = wp_get_attachment_image_src($thumb_id, 'slider1', true)
    
    ***RELEVANT PART***
    		if(has_term( 7, 'term_id' )) { 
    		    $hideexcerpt = " no-excerpt";
    		} else {
    		    $hideexcerpt = "";
    		}
    		
    		if(has_term( 8 )) { 
    		    $hidetitle = " no-title";
    		} else {
    		    $hideexcerpt = "";
    		}
    
    ***END RELEVANT PART***
    
    		$content .= '<li><div class="slider-post ';
    		$content .= '"><a href="';
    • This reply was modified 5 years, 4 months ago by joefedorowicz.
    Thread Starter joefedorowicz

    (@joefedorowicz)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using has_term’ is closed to new replies.