Support » Plugins » Hacks » Adding an autoname property to category page

  • Hi there,

    I’m very inexperienced with PHP coding and am having issues with what I’m assuming is a relatively easy issue to fix.

    I’m attempting to customize the category pages on my website, so that when you click on the category page, a customized banner and title will come up. I want to customize the code so that the category ID tag will automatically be displayed as a header title. So if the category ID is “Doctors,” the page will automatically display “Doctors” as a header.

    I’ve isolated this code in one of my themes template pages:

    echo '<div class="widget-head"><h3><a>cat_ID).'" title="View all posts under '.$cat->cat_name.'">'.$cat->cat_name.'</a></h3></div>';

    I think this will do what I want it too, but I’m not sure how to correctly write the code.

    Any help would be appreciated, thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Ok I solved this issue by adding the single_cat_title as so:

    <p><?php single_cat_title('Currently browsing '); ?>.

    What I would like to know now is whether or not I can do the same thing with a designated image or banner.

    For example, when the category page for “Doctors” is opened, a banner or image appears with the text provided from the code above.

    Is this doable?


    Moderator bcworkz


    It’s doable, but not as simply as the solution you found for the title. There’s a few possibilities. You could build an array that relates category ID to the image filename:

    <?php $images = array(
       8 => 'doctors.jpg',
      13 => 'nurses.jpg',
      21 => 'cnas.jpg',
    ); ?>

    Then output the image tag referencing the array:
    <img src="http;//<?php echo $images[ $cat->cat_ID ] ?>" alt="Banner Image">

    Thanks for responding,e

    I actually figured it out earlier today, I installed the ‘Categories Images’ plugin, and then used the following command to automatically pull the cat image:

    <img src="<?php echo z_taxonomy_image_url($term->term_id); ?>" />

    But thanks for the array code, I’ve been wondering how to correctly utilize something like that.



Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding an autoname property to category page’ is closed to new replies.