• Resolved nadine00

    (@nadine00)


    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Change

    'category' => 10,

    to

    'category' => '1,2,3',

    Thread Starter nadine00

    (@nadine00)

    Thank you. ??

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

    You’d have to build your own ‘list book marks’

    Thread Starter nadine00

    (@nadine00)

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

    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 https://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]

    Thread Starter nadine00

    (@nadine00)

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

    Nadine.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wp_list_bookmarks question’ is closed to new replies.