• Im trying to display a set of category header images using the Custom Tax Image plugin.

    But I want to only display the image if the image is available, and if it is available I want to display different set of <h1> text depending on what category you are viewing.

    So it would be a If statement inside a If statement.

    This is what I currently have. But it is not working.


    <?php if (function_exists('z_taxonomy_image_url')) {
    if (cat_is_ancestor_of(392, $cat)) {
    echo '<div id="cat-header"><img id="cat-banner" src="' . z_taxonomy_image_url() . '"><p>Restaurants Serving</p><h1>' . single_cat_title(); . '</h1>' . ft_custom_breadcrumbs(); . '</div>';
    } elseif (is_category('392')) {
    echo '<div id="cat-header"><img id="cat-banner" src="' . z_taxonomy_image_url() . '"><p>Restaurants By</p><h1>' . single_cat_title(); . '</h1>' . ft_custom_breadcrumbs(); . '</div>';
    } else {
    echo '<div id="cat-header"><img id="cat-banner" src="' . z_taxonomy_image_url() . '"><p>Restaurants In</p><h1>' . single_cat_title(); . '</h1>' . ft_custom_breadcrumbs(); . '</div>';
    }
    } else {
    echo '<div id="cat-header"><p>Restaurants Serving</p><h1>' . single_cat_title(); . '</h1>' . ft_custom_breadcrumbs(); . '</div>';
    }?>

Viewing 1 replies (of 1 total)
  • The biggest error is in these lines:

    echo '<div id="cat-header"><img id="cat-banner" src="' . z_taxonomy_image_url() . '"><p>Restaurants By</p><h1>' . single_cat_title(); . '</h1>' . ft_custom_breadcrumbs(); . '</div>';

    You have to remove the ;’s in the middle of those lines. Each line can have exactly one semi-colan, and it has to be at the end, signifying the end of that line for processing. As an example, that line should be:

    echo '<div id="cat-header"><img id="cat-banner" src="' . z_taxonomy_image_url() . '"><p>Restaurants By</p><h1>' . single_cat_title() . '</h1>' . ft_custom_breadcrumbs(; . '</div>';

    It’s a small mistake and easy to do, but it will break a whole lot of stuff.

Viewing 1 replies (of 1 total)
  • The topic ‘conditional statements’ is closed to new replies.