WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_list_bookmarks question (7 posts)

  1. nadine00
    Member
    Posted 4 years ago #

    Hi,

    I have a quick question about wp_list_bookmarks() I would like to display links from more than one specific category. So for example:

    category 1 OR category 2 OR category 3

    How do I do that within this setup:

    <?php $link_args = array(
    'category' => 10,
    'orderby' => 'name',
    'order' => 'DESC',
    'categorize' => 0,
    'title_li'=> __(''),
    'show_description' => 1,
    'class' => 'link_test',
    );?>

    Thank You

    Nadine.

  2. MichaelH
    Member
    Posted 4 years ago #

    Change

    'category' => 10,

    to

    'category' => '1,2,3',
  3. nadine00
    Member
    Posted 4 years ago #

    Thank you. :)

    Is there a way to keep links that are in two categories from displaying twice in the same list?

  4. MichaelH
    Member
    Posted 4 years ago #

    You'd have to build your own 'list book marks'

  5. nadine00
    Member
    Posted 4 years ago #

    Do you have any links to references where I can learn to do that? Please, and thank you.

  6. MichaelH
    Member
    Posted 4 years ago #

    You'll probably want to look at wpdb and then Displaying_Posts_Using_a_Custom_Select_Query <--that talks about categories for posts, but can also be used for links.

    Also look at the get_bookmarks function for example of the query and this for the sql http://dev.mysql.com/doc/refman/5.1/en/select.html

    <?php
    $query = "SELECT DISTINCT link_id FROM $wpdb->links
    INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id)
    INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
    WHERE 1=1
    AND link_visible = 'Y'
    AND ( tt.term_id = 4  OR tt.term_id = 10  OR tt.term_id = 113 )
    AND taxonomy = 'link_category'";
    $link_ids = $wpdb->get_col($query);
    $args=array(
      'include' => implode(',', $link_ids),
      'orderby' => 'name',
      'order' => 'DESC',
      'categorize' => 0,
      'title_li'=> __(''),
      'show_description' => 1,
      'class' => 'link_test',
    );
    wp_list_bookmarks($args);
    ?>

    [note deleted the word "quick" from the topic subject]

  7. nadine00
    Member
    Posted 4 years ago #

    Woo! That worked. Thank you! And thanks for the reference page links as well. :)

    Nadine.

Topic Closed

This topic has been closed to new replies.

About this Topic