• Hi!

    I would like to show my bookmarks in 11 different pages, one for each category. Do I need to make a templatefile for each category or is there any way to add the code for getting the bookmarks of a specific category direcly onto the page of choise?

    http://www.modellrallaren.se

    /Jocke

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can switch what to show on each category by using in_category().

    Thread Starter cimson

    (@cimson)

    Thanks for your answer! But how do I choose what category I want to display on each page? Is there a way to “call” for the content when editing my linkpages or do I need to make 11 different link-template files?

    /Jocke

    Sorry I misunderstood the question. Different pages for each category templates – alright, how about this:

    Simplest way is change the code in the Links template to this:

    <?php $link_cat = get_post_meta($post->ID, 'link_cat', true);
    wp_list_bookmarks('category=' . $link_cat); ?>

    and add a custom field with key:link_cat and category ID in value.

    Another way is to use a shortcode. Place this code:

    function bookmarks_shortcode($attrs = array(), $content = null) {
      return wp_list_bookmarks($attrs);
    }
    add_shortcode('bookmarks', 'bookmarks_shortcode');

    in the functions.php in theme directory, and add [bookmarks] in the content.

    <ul>
    [bookmarks category=2]
    </ul>

    You can use this in any Posts/Pages and Templates.
    The same options as the wp_list_bookmarks template tag can be used to control the output.

    Thread Starter cimson

    (@cimson)

    Thank you so much! It worked perfect with the shortcode!

    Is there a parameter to exclude the showing of the name of the category, have it also as titel of the pages and it feels a bit stupid to print it twice on each page (ex. http://www.modellrallaren.se/?page_id=377) The “category_name” isn’t about excluding the name as far as I understod.

    /Jocke

    Good to hear it worked.

    To hide the category name,
    haven’t tried but this should do:

    [bookmarks category="2" categorize="0" title_li=""]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bookmarks on different pages’ is closed to new replies.