[resolved] RSS feed_image on the *left*? (17 posts)

  1. parakeet
    Posted 9 years ago #

    Does anyone know how to get feed_image to appear on the *left* (as opposed to the right) of a category title link?

    I've tinkered with CSS and the code in template-functions-category.php - all to no avail.

    Anyone have any tips/plugins/code please?

  2. manstraw
    Posted 9 years ago #

    more information is needed, like a link to your example site.

    is the image done in CSS? Or is it linked as an image in the html?

  3. parakeet
    Posted 9 years ago #


    It's accomplished using the following code...


      <?php wp_list_cats('sort_column=name&optioncount=1&exclude=10,15,2,75&feed_image=/wp-content/themes/minid/images/rss/feed-icon-10x10.gif'); ?>

    ... That is, stating the feed_image parameter when calling wp_list_cats


  4. manstraw
    Posted 9 years ago #

    ok, gotcha.

    that needs a modification to the wp-list-cats function. hmm, has there been a plugin that overrides that? I've tried shoving them around with css, but couldn't quite get there.

    how do you feel about modifying your core wordpress files?

    another option might be to duplicate the function, give it a different name, customize that one, and then use it instead. maybe you can put it in your theme's functions.php file. Are you up for that sort of task? This would give you an upgrade friendly, theme specific change.

    Or what if you just right justified the whole list in css? You'd get a neater list, if the ragged appear of the icons is what is bothering you.

  5. parakeet
    Posted 9 years ago #

    Definitely prepared to modify code; just not certain how. In template-functions-category.php, I found the portion in which feed_image is processed, cut it and inserted it above the portion where the category title link is generated - but that doesn't work.

    A plugin would be ideal but I haven't been able to find one, surprisingly.

    I tried floating the image left, but it staggers the whole list.

    Not certain about duplicating the function. Do you mean moving the relevant parts from template-functions-category.php to functions.php? Would still have to be modified, right?

    Right-aligning everything could be a last resort; good thinking.

    I did come across a modified template .phps someone hacked back in 2004 but it won't work at all, presumably because the core files are substantially different from pre-2.0 WP.

    Hmmmm :/


  6. manstraw
    Posted 9 years ago #

    If you found the function, that's the first step. I'm not a fan of modifying core files, but I've never replace a function before, so this is all I can advise.

    Inside list_cats, immediately after $num_found++;, put this:

    $link = ''; //note this is two single quotes

    Then move everything from
    if ( (! empty($feed_image)) || (! empty($feed)) ) {
    to it's closing } to right after our new $link = ''; statement.

    Then change this (should be the very next thing after our additions):
    $link = '<a href="'.get_category_link($category->cat_ID).'" ';

    $link .= '<a href="'.get_category_link($category->cat_ID).'" ';

    (the only change is a . before the =

    If it borks, just replace the file with your backup, and we'll try again. Hopefully you'll have what you want. This is modifying a core file though, so it will break during an upgrade. If someone else can advise how to replace this function with a plugin, then great.

  7. Doodlebee
    Posted 9 years ago #

    You could put this in your stylesheet:

    div.principal li a img {float:left;margin-top:-13px;}
    div.principal li a {clear:left;padding-left:13px;}

    However, if the link is more than one line long (see "Usability and User Experience") it'll look funky. But it works...

  8. manstraw
    Posted 9 years ago #

    i tried doing something like that doodlebee, but I couldn't quite get it. You've gotten closer than I did, but it still cocks up in a couple of places like you said. Perhaps if he could shorten some of his category names.

  9. whooami
    Posted 9 years ago #

    you want this?


    I did that on an older install, some time ago. Making it work in 2.0.4 wasnt much harder since I backup files. I can post the code for you that you need to change inside template-functions-category.php OR i can pluginize it.

    Up to you, its a fair amount of edits, and I really dont want to post a ton of code to this thread.

    In fact, I prefer this but due to my nifty category menu on my live site cant have it that way right now.

  10. manstraw
    Posted 9 years ago #

    I would prefer if you would pluginize, so I can look to see how you do that. I've not done anything like this yet, so I would appreciate it as a learning experience. no problem if you'd rather not.

  11. whooami
    Posted 9 years ago #

    I wonder, if I would need to duplicate that whole list_cats function, prolly so.

  12. vkaryl
    Posted 9 years ago #

    *holler when you want that link broken....* and yeah, I think you'd have to dupe the whole function.

  13. whooami
    Posted 9 years ago #

    damn that was a bit of work to get that nested list stuff to validate, i detest nested lists but it looks like it does work (atleast with kubric).

    This wont take long.

  14. whooami
    Posted 9 years ago #

    done, see http://wordpress.org/support/topic/86040?replies=1#post-439240

    and if someone would break that url above, I would be most overjoyed.


  15. parakeet
    Posted 9 years ago #

    Okay, some real progress here.

    * Thanks to manstraw. You suggested modifications to the core file work a treat. I was oh so close to having that sort of tweak nailed before I had to seek help; you got me there.

    * Thanks to whooami for making the plugin version. This way, I guess I'm able to reproduce the effect but leave the core files in tact. Excellent.

    Thanks, all. A useful contribution and addition to the plugin base, I'm sure.

  16. vkaryl
    Posted 9 years ago #

    Done, whoo....

  17. mazdakam
    Posted 9 years ago #

    this is my hack it's similar to manstraw:

    go to wp-includes\classes.php

    find this` if ( (! empty($feed_image)) || (! empty($feed)) ) {
    $link .= ' ';

    if ( empty($feed_image) )
    $link .= '(';

    $link .= 'cat_ID, $category->category_nicename ) . '"';

    if ( empty($feed) )
    $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
    else {
    $title = ' title="' . $feed . '"';
    $alt = ' alt="' . $feed . '"';
    $name = $feed;
    $link .= $title;

    $link .= '>';

    if ( empty($feed_image) )
    $link .= $name;
    $link .= "<img src='$feed_image'$alt$title" . ' />';
    $link .= '
    if ( empty($feed_image) )
    $link .= ')';
    it must be on line no. 592

    Then copy it after $cat_name = attribute_escape( $category->cat_name);

    Then replace $link .= '<a href="' . get_category_rss_link( 0, $category->cat_ID, $category->category_nicename ) . '"';

    with this $link = '<a href="' . get_category_rss_link( 0, $category->cat_ID, $category->category_nicename ) . '"';

    the only change is a . before the =

Topic Closed

This topic has been closed to new replies.

About this Topic