WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_bookmarks in foreach don't work (2 posts)

  1. alanicolasouza
    Member
    Posted 1 year ago #

    Hey everyone.

    The $categories is a array with the category slug. This code works just to the first cycle, which means, only the first category is printing.

    foreach($categories as $category){
      if( wp_list_bookmarks('category_name='.$category.'&echo=0') ){
            wp_list_bookmarks( 'title_li=&category_name='.$category.'&before=<li>&orderby=name' ).
      }
    }
  2. Franky57
    Member
    Posted 1 year ago #

    Hi !

    category_name is the "name" of your category, not the "slug"

    If your category name is "Exemple", the slug will be "exemple" and wp_list_bookmarks will work because the function is not case sensitive for category_name

    However, if your category name is "My Category Name", the slug will be "my-category-name" and wp_list_bookmarks will not work

Topic Closed

This topic has been closed to new replies.

About this Topic