Bookmarks on different pages (6 posts)

  1. cimson
    Posted 7 years ago #


    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?



  2. yoshi
    Posted 7 years ago #

    You can switch what to show on each category by using in_category().

  3. cimson
    Posted 7 years ago #

    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?


  4. yoshi
    Posted 7 years ago #

    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.

    [bookmarks category=2]

    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.

  5. cimson
    Posted 7 years ago #

    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.


  6. yoshi
    Posted 7 years ago #

    Good to hear it worked.

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

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.