• I am customizing my sidebar headers to display images instead of text. I have replaced all of them except “Blogroll”, because I can’t figure out where it lives. Where can I find the word “blogroll”? Thanks very much. https://scraster.com/blog

Viewing 3 replies - 1 through 3 (of 3 total)
  • It depends, at least a little, on how the blogroll section is being displayed in your sidebar. Are you using widgets to display your sidebar code or just functions listed in the sidebar.php file?

    Typically the blogroll text is found in the Link Categories page in the WordPress backend. You can change the text to whatever you like there, but I don’t believe you can specify an image.

    How the blogroll is being displayed in your sidebar will determine how best to replace that text with an image.

    There are a few ways to swap out text headings with images in WordPress. The “Blogroll” heading is a bit tricky. However you can swap the term “Blogroll” by editing the bookmark-templates.php file included in the WordPress package.

    * These steps assume the desired image name is dummy.gif
    Step 1. – Upload your image to wp-content/themes/default/images/dummy.gif
    Step 2. – Open the installed bookmark-templates.php file
    Step 3. – Back up bookmark-templates.php with different name
    (worse case scenario measure)
    Step 4. – Find and edit the function named wp_list_bookmarks
    Step 5. – Create a variable name $img and define it within the first line of the wp_list_bookmark function
    Step 6. – Alter the defaults array replacing (“Blogrolls”) with ($img) and change the 1 to a 0, which is found next to ‘categorize’ in the default array
    Step 7. – Save and upload the file. Double check that the image path is correct and also that any quotes in the path are escaped properly

    When finished the default array should look something like this.

    function wp_list_bookmarks($args = '') {
    
    $img = "<img src=\"https://dummy.com/blog/wp-content/themes/default/images/dummy.gif\" alt=\"Swap Text for Image\"/>";
    
    $defaults = array(
      'orderby' => 'name', 'order' => 'ASC',
      'limit' => -1, 'category' => '', 'exclude_category' => '',
      'category_name' => '', 'hide_invisible' => 1,
      'show_updated' => 0, 'echo' => 1,
      'categorize' => 0, 'title_li' => __($img), //changed from 1
      'title_before' => '<h2>', 'title_after' => '</h2>',
      'category_orderby' => 'name', 'category_order' => 'ASC',
      'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">','category_after' => ''
    );
    
    //LEAVE THE REST ALONE ...

    A more upgrade friendly way of doing this, might be editing the sidebar.php in your theme folder, found in wp-content/themes/

    Find <?php wp_list_bookmarks(); ?>

    and change it to:

    <?php wp_list_bookmarks(‘categorize=0&title_li=<img src=”‘.get_bloginfo(“stylesheet_directory”).’/images/dummy.gif” alt=”blogroll” />’); ?>

    This will use “dummy.gif” in the images folder in your theme. Also, it makes the theme portable, so other people can use it without messing with the WordPress installation ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Replacing sidebar text “Blogroll” with blogroll image’ is closed to new replies.