WordPress.org

Ready to get started?Download WordPress

Forums

Category Icons
Icons not appearing (20 posts)

  1. Pete
    Member
    Posted 1 year ago #

    I have the latest version of WordPress installed. I'm using the City Guide template from WooThemes. I've installed and activated the icon and associated some icons to categories. In the Category Icons admin area I see the quantity of posts each icon belongs to.

    I've added <?php if (function_exists('get_cat_icon')) get_cat_icon(); ?> within the loop of archive.php which is displaying the categories pages in the template.

    Does it matter that i'm using it on a category page? I've used this plugin before and it worked just fine with the same function just in another template file.

    Looking at the source I don't see any html being rendered for the icon just the div it's wrapped in.

    Any suggestions on what I can try?

    Thanks

    http://wordpress.org/extend/plugins/category-icons/

  2. Pete
    Member
    Posted 1 year ago #

    I saw on my template tag page I need to replace a function in archive.php which I have but I get a syntax error

    $catlist = if (function_exists('put_cat_icons')) {
    put_cat_icons( wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id.'&echo=0'));
    } else {
    wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id);}

    The code it's telling me to replace is after the = sign. If I remove the variable $catlist = the function has no syntax errors. What's the problem in the code?

  3. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    1. My advice would be to remove the code you pasted in archive.php (or replace it by the original file) and then use the template tags panel : it'll show you exactly where to echo the category icons.

    2. I think you can't do this in PHP : $catlist = if (...) else (...)
    It should be (if you want to use one line of code) :
    $catlist = function_exists('put_cat_icons') ? put_cat_icons( wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id.'&echo=0')) : wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id) ;

    OR, you can use the widget. ;-)

  4. Pete
    Member
    Posted 1 year ago #

    Apparently I can't do that in PHP but that function isn't working either. I use it to display a list of children categories. This is the entire code below. When I update the function it displays the children categories as well as the string "Please don't porint Not categories" so something is wrong. The icons still do not show up either using that function. I can't use a widget I need the icons in the template. I've done it before just never in an archive.php template.

    <?php // list child categories
    $catlist = wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id);
    
    if ($catlist) {
    echo '<ul class="subcatstate">'. $catlist .'</ul>';
    } else {
    echo "Please don't print No categories";
    } ?>
  5. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I've tested this, it's working :

    $catlist = function_exists('put_cat_icons') ? put_cat_icons( wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id),'echo=false') : wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id) ;
    echo $catlist;

    So, to get the icons in a variable :

    $caticons = put_cat_icons( wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id),'echo=false');

    wp_list_categories() does not return a boolean, so the string "Please ... categories" is displayed. Here is the doc for wp_list_categories.

  6. Pete
    Member
    Posted 1 year ago #

    I think I know what part of the problem is. That function above is only being used to display an un ordered list of sub-categories. These don't have icons.

    On the category page that is listing all the posts within that category I placed <div class="caticon"><?php if (function_exists('get_cat_icon')) get_cat_icon(); ?></div> within the post loop. It should be displaying an icon over each posts featured image. The CSS is correct that's not the problem here's the complete code for the page. You'll see where I have <?php if (function_exists('get_cat_icon')) get_cat_icon(); ?> when the page loads that div is completely empty. Where else should I be placing the put_cat_icons function?

    <?php get_header(); ?>
        <!-- Maps Module -->
    	<?php if (get_option('woo_show_archive_map') == 'true') { include (TEMPLATEPATH . "/includes/featured-archive.php"); } else {?><div class="spacer"></div><?php } ?>
    	<!-- Maps Module end -->
    
        <div id="content" class="col-full">
    		<div id="main" class="col-left">
    
    		<?php if (have_posts()) : $count = 0; ?>
    
                <?php if (is_category()) { ?>
                <span class="archive_header"><span class="fl cat"><?php _e('Golf Courses', 'woothemes'); ?> | <?php echo single_cat_title(); ?></span> <span class="fr catrss"><?php $cat_obj = $wp_query->get_queried_object(); $cat_id = $cat_obj->cat_ID; echo '<a href="'; get_category_rss_link(true, $cat, ''); echo '">RSS feed for this section</a>'; ?></span></span>
                            <?php // list child categories
    						$catlist = wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id);
    
    						if ($catlist) {
    						echo '<ul class="subcatstate">'. $catlist .'</ul>';
    						} else {
    						echo "Please don't print No categories";
    						} ?>
    
                <?php } elseif (is_day()) { ?>
                <span class="archive_header"><?php _e('Archive', 'woothemes'); ?> | <?php the_time(get_option('date_format')); ?></span>
    
                <?php } elseif (is_month()) { ?>
                <span class="archive_header"><?php _e('Archive', 'woothemes'); ?> | <?php the_time('F, Y'); ?></span>
    
                <?php } elseif (is_year()) { ?>
                <span class="archive_header"><?php _e('Archive', 'woothemes'); ?> | <?php the_time('Y'); ?></span>
    
                <?php } elseif (is_author()) { ?>
                <span class="archive_header"><?php _e('Archive by Author', 'woothemes'); ?></span>
    
                <?php } elseif (is_tag()) { ?>
                <span class="archive_header"><?php _e('Tag Archives:', 'woothemes'); ?> <?php echo single_tag_title('', true); ?></span>
    
                <?php } ?>
    
                <div class="fix"></div>
    
                <div id="posts_outer">
    
            <?php while (have_posts()) : the_post(); $count++; ?>
    
                <!-- Post Starts -->
                <div class="post">
               			<?php
                		$img_missing = false;
    					if (woo_image('return=true&key=image')) { ?>
                		<div class="image-holder <?php echo $GLOBALS['thumb_align']; ?>" style="width:<?php echo $GLOBALS['thumb_w']; ?>px">
                			<?php woo_get_image('image',$GLOBALS['thumb_w'],$GLOBALS['thumb_h'],'thumbnail '.$GLOBALS['thumb_align']); ?>
                			<div class="fix"></div>
                       		<?php if(function_exists('the_ratings')) { echo '<div class="ratings fl">'; the_ratings(); echo '</div>'; } ?>
                            <div class="caticon"><?php if (function_exists('get_cat_icon')) get_cat_icon(); ?></div>
                		</div>
                         <?php } else { $img_missing = true; } ?>
    
                        <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
                        <p class="post-meta">
                           <span class="comments"><?php comments_popup_link(__('0 Comments', 'woothemes'), __('1 Comments', 'woothemes'), __('% Comments', 'woothemes')); ?></span>
                        </p>
    
                        <?php if($img_missing == true) {
    					if(function_exists('the_ratings')) { echo '<div class="ratings fl">'; the_ratings(); echo '</div>'; } ?>
    					<p class="categories"><span class="post-category"><?php the_category(' ') ?></span></p>
    					<?php }?>
    
                        <div class="entry">
                            <?php the_excerpt(); ?>
                        </div>
                        <div class="cat-course-info">
                        <p><span class="ci-par">Par: <?php the_field('par');?></span><span>Metres: <?php the_field('metres');?></span><span>ACR: <?php the_field('acr');?></span></p>
                        </div>
                        <div class="fix"></div>
    
                    </div><!-- Post Ends -->
    
            <?php endwhile; ?>
    
            	</div>
    
            <?php else: ?>
                <div class="post">
                    <p><?php _e('Sorry, no posts matched your criteria.', 'woothemes') ?></p>
                </div><!-- /.post -->
            <?php endif; ?>  
    
    			<?php woo_pagenav(); ?>
    
    		</div><!-- /#main -->
    
            <?php get_sidebar(); ?>
    
        </div><!-- /#content -->
    
    <?php get_footer(); ?>
  7. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry, but I have to ask : did you use the template tags panel ? What did it tell you on the location in archive.php ? If not, please, use it : http://www.category-icons.com/2008/03/where-to-add-the-get_cat_icon-function/

  8. Pete
    Member
    Posted 1 year ago #

    I replaced the code it told me to on the template tags panel same line and column I don't think it's accounting for the variable. Haven't had trouble with this plugin before. On this same install if I place <?php if (function_exists('get_cat_icon')) get_cat_icon(); ?> into single.php it works just fine.

  9. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    If I wanted to display category icons just before the posts title, I would do that at line 58 of your code :

    <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php if (function_exists('get_cat_icon')) get_cat_icon('class=caticon'); ?><?php the_title(); ?></a></h2>

    I think you should use Firebug to help you (as well as with CSS) find the exact location if you're not sure. It would help me if you give a link to your website.

  10. Pete
    Member
    Posted 1 year ago #

    I use Chrome developer tool. Placing the php function there doesn't work either and shouldn't make ad difference between my current location. Since it's still within the post. I have it overlayed on the featured image.

    The featured image div has it's position set to relative, the category icon set to absolute. Viewing the source in chrome developer tool nothing renders on the page. Yet if I use the same code to display the icon in single.php it works just fine.

  11. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    Can you provide a screenshot (http://imgur.com), please ? I don't see what you want to do, so I can't help you efficiently.

  12. Pete
    Member
    Posted 1 year ago #

    Here's a web cast showing what i've done so far

    http://www.screenr.com/Mzu8

    The wp list category function I have in archive.php is used to display an un ordered list of children categories.

    That's the code the template tag page is telling me to replace but that only has to do with the sub categories list.

    I need to place the category icon over my post featured images. I have the CSS setup correctly and the php code placed correctly so I don't know why it's not working.

    Really appreciate the help thanks a lot

  13. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    From what I've seen and understood (as I don't have your theme : it's a premium theme), I'd do that :
    1. At line #14 of your code (to replace entirely line #14 to #20) in order to display the icon assigned to the children categories:

    $catlist = function_exists('put_cat_icons') ? put_cat_icons( wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id),'echo=false') : wp_list_categories('echo=0&orderby=id&show_count=1&title_li=&child_of=' . $cat_id) ;
    echo '<ul class="subcatstate">'.$catlist.'</ul>';  ?>

    2. At line #59, to display the category icon just before the title :

    <h2 class="title"><?php if (function_exists('get_cat_icon')) get_cat_icon(); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>

    And in your CSS, something like this to make the horizontal list :

    ul.subcatstate > li {
        display: inline;
    }

    As this is a category page, the icon in front of the title will be the same for all the post : it's the icon assigned to the category.

  14. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I think that because of the woo_image() function, your icon will be displayed only if one of the following conditions is OK :

    This function retrieves/resizes the image to be used with the post in this order:

    1. Image passed through parameter 'src'
    2. WP Post Thumbnail (if option activated)
    3. Custom field
    4. First attached image in post (if option activated)
    5. First inline image in post (if option activated)

    If it's not OK, the icon won't be displayed. That's why I told you to put the function outside the woo_image.

  15. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, sorry I've missed the fact that the icon was overlayed. In this case, you're right, you have to put it in the woo_image block. My bad. But this does not solve the problem.

  16. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I had some time to have a look at the function woo_image and I think that if there is a thumbnail for the post, the icon will be displayed. If not, then no icon. I saw that there is an option named "framework_woo_default_image". I bet that if you set a default image, the icon will always be displayed. Try to delete the following lines :

    if (woo_image('return=true&key=image')) {

    and this one :

    } else { $img_missing = true; }

    to see what happens. I can't help you more on this, as it is not related to the plugin : it's a theme "issue".

    Good luck.

  17. Pete
    Member
    Posted 1 year ago #

    Thanks i'll go over their functions and your suggestions and let you know what works. If I don't have any luck getting it to work i'll post in their support forum and link to this thread to see what their devs can come up with.

  18. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I slept a little and here is a solution : replace the code at line #57 :

    <?php } else { $img_missing = true; } ?>

    by this one :

    <?php
     } else { // no thumbnail
        $img_missing = true;
        if (function_exists('get_cat_icon')) { // if category icons is active
     ?>
     <div class="image-holder">
    	<div class="fix"></div>
    	<p class="fr"><span class="post-category"><?php the_category(' ') ?></span></p>
    	<?php get_cat_icon(); ?>
    </div>
     <?php
        }
     }
     ?>

    If there's no thumbnail to display, and if the plugin category icons is active, display the icon.

  19. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I think this is because of this code in category-icons.php :

    if (is_category() && in_the_loop()) {
    		$cat = (int) get_query_var('cat');
    		$category=get_category($cat);
    		if (!isset($p['cat']) || !is_array($p['cat'])) {
        		$p['cat']=array();
    		}
    
        	$p['cat'][] = $category->cat_ID;
    	}
    	else {

    Delete it, and also the corresponding closing curly braket : }, just before :

    $nb_icons = 0;
  20. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I've updated the plugin to 2.2.3. It should be resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags