ThemeShaper Forums » Thematic

[closed]

Showing Link Descriptions on the links.php Template

(6 posts)
  • Started 4 years ago by theorib
  • Latest reply from JimDandy
  • This topic is resolved
  1. Hi all,

    I'm still not comfortable with PHP though I manage myself well with XHTML and CSS.

    I was wondering if there is a way of showing Link Descriptions on the links.php page template without modifying the defaults on the wordpress bookmark-template.php file itself.

    I don't know how to do it but I would guess there would be a way for modifying the 'show_description' => 0 to 'show_description' => 1 in the functions.php file of my themelet.

    Also, on the links page, I need to output something like this:
    'between' => '<span class="between">|</span>', and $output .= $between . '<span class="link-desc">' . $desc . '</span>';
    Instead of the defaults:
    between' => "\n", and $output .= $between . $desc;

    Can it be done through functions.php?

    Thanks loads in advanced!

    Posted 4 years ago #
  2. Ok, I figured out a way to do the first thing (showing the description) by putting a copy of the links.php file in my child theme folder and replacing the:
    <?php wp_list_bookmarks(list_bookmarks_args()) ?>
    by
    <?php wp_list_bookmarks('show_description=1','list_bookmarks_args()') ?>

    Though this works I reckon there must be a much "nicer, cleaner and right" way to do it using something like filter hooks or action hooks in my functions.php file but even though I read Ian's great tutorials on both things I still can't find the way to do it...

    Any help would be much appreciated to learn more about PHP!

    Thanks loads, Thematic is awesome!

    Posted 4 years ago #
  3. Hi Theo,

    the one and only advice: Don't touch that Theme! :)

    Ok .. the list_bookmarks_args() filter function was build to hand the needed arguments over to wp_list_bookmarks().

    Create a function that returns the arguments you want to use for wp_list_bookmarks():

    function my_list_bookmarks_args() {
        // the default args
        $content = 'title_before=<h2>&title_after=</h2>';
        $content. = '&show_description=1';
        return $content;
    }
    add_filter('list_bookmarks_args', 'my_list_bookmarks_args');

    If you want to leave the default args in there (the above code sample is just to show what's already there), you can shorten the above code:

    function my_list_bookmarks_args($content) {
        $content. = '&show_description=1';
        return $content;
    }
    add_filter('list_bookmarks_args', 'my_list_bookmarks_args');

    Chris

    Posted 4 years ago #
  4. Chris you are awesome, thanks! That works wonders!

    If someone else looks for this in the future, there was an extra dot that messed-up the code above, the correct one should be:

    function my_list_bookmarks_args() {
        // the default args
        $content = 'title_before=<h2>&title_after=</h2>';
        $content. = '&show_description=1';
        return $content;
    }
    add_filter('list_bookmarks_args', 'my_list_bookmarks_args');

    I'll look at how to style the between with the info you gave me!

    Posted 4 years ago #
  5. For the record if anyone is interested, here is the final code sniplet I used to solve my initial post proposition, changing the output code and showing description on the links.php page template:

    // Customizes the output on the links.php page template
    function my_list_bookmarks_args() {
        // the default args
        $content = 'title_before=<h2>&title_after=</h2>&show_description=1&between=<span class="between">|</span><span class="link-desc">&after=</span></li>&order=DESC&orderby=id';
        return $content;
    }
    add_filter('list_bookmarks_args', 'my_list_bookmarks_args');
    Posted 4 years ago #
  6. JimDandy
    Member

    Can I ask a question 7 months after the last post in this thread? Well, here goes.

    I'm pretty boneheaded when it comes to PHP, although I understand it in theory. Anyway, if I want to pull in named anchors for my link categories on my links page, what do I need to add to the content filter, as above? I've successfully modified the category_before argument to add a named anchor, but have only had success using the id variable (because it's a documented variable, and my comprehension ends there!):

    $content = 'category_before=<li id="%id" class="%class"><a name="%id"></a>&...

    So my question is how could I change that named anchor to pull in the category name, if I wanted to do that. I don't know if I'll actually go that route, since the name could include spaces, and I'd probably need to do a reg_exp filter on it to make it usable as a tag parameter, but I figure I should try to learn something in the process. Thanks.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.