One more error_log notice

  • Josh


    Sorry Syahir.. I’ve been on a debugging frenzy for a client.

    Here is one more I spotted:

    Undefined variable: tax in /home/josh401/public_html/wp-content/themes/graphene/includes/theme-loop.php on line 542

    This can be tested by going to any category page, and then viewing the error log. Refreshing the category page generates a new notice in the log.

    Here is the associated function:

    function graphene_tax_description(){
    global $wp_query;
    if ( $wp_query->queried_object ){
    $term = $wp_query->queried_object;
    } else {
    $tax = $wp_query->tax_query->queries[0]['taxonomy'];
    $term = $wp_query->tax_query->queries[0]['terms'][0];
    $term = get_term_by( 'slug', $term, $tax );

    if ( ! $term ) return;

    if ( $term->description ) :
    <div id="term-desc-<?php echo $term->term_id; ?>" class="<?php echo $tax; ?>-desc term-desc">
    <?php echo $term->description; ?>
    <?php endif;

    It seems $tax is not being defined if the $wp_query->queried_object is retuning true.

    For the time being, I added $tax = $wp_query->tax_query->queries[0]['taxonomy']; at the end of the first if statement… which seems to define $tax.

    But.. I’m not sure that this is the best solution.

    Thank you!!!!



    I see what is happening now.

    I suppose it would be best to use the slug or the nicename from the $wp_query->queried_object (if returned true)… as this would still allow each one to be unique.

    Awaiting your thoughts 🙂


    Syahir Hakim


    Just add:

    $tax = $term->taxonomy;


    $term = $wp_query->queried_object;



    Got it.

    Thank you!

    Wait. Won’t that just return the word category?

    Just thinking ahead… but if someone, for whatever reason, needed to target different categories based on class name… wouldn’t it be better to use something unique to each category?


    Syahir Hakim

    <div id="term-desc-<?php echo $term->term_id; ?>" class="<?php echo $tax; ?>-desc term-desc">

    The ID attribute above already covers that.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.