Get a list with all the subsites of a certain categorie

i would like to get a list with all the subsites of a certain
i already works fine with the widgets of the plugin, but i need the actual code, because want to put it in a flyout.
i think in this thread,
the answer is quite near, but i dont really know how to deal with it.
a appreciate some help with it.

  • zeixcom
    • WPMU DEV Initiate

    hi tom,
    thanks for your answer.
    i already have a custom flyout working, but thanks for pointing out the "slide-in" plugin.

    i tried the code from the line 503 - 550, but i did'nt get the list.
    do i have to put in an <echo> somehwere?

    in the plugin folder, i have the folder "lib" and there "display_templates".
    if i take the code from "display_list_category_sites.php" and put in the flyout,
    i get an error: Cannot redeclare process_site_categories_landing_list_sites_display()
    i tried some "echo's", but cannot get it to work.

    thanks in advance

  • Paul
    • The Green Incsub


    Greetings. Yeah, the display_list_category_sites.php file is others are used for display output. And yes, you can't just copy the file into your own unless you go through and change the function names.

    What you first need to understand about Site Categories is how is stores the data. Instead of using a custom DB table we leverage the Taxonomy system within WordPress. On the primary site ONLY there is a custom taxonomy 'bcat' where you can directly query what you are after.

    Probably a better example is the Widget code used to display the sites within a category lib/widgets/class_site_categories_widget_category_sites.php lines 185-187

    switch_to_blog( $current_site->blog_id );
    $bcat_term = get_term($instance['category'], SITE_CATEGORIES_TAXONOMY);
    $sites = $site_categories->get_taxonomy_sites($instance['category'], $instance['include_children']);

    The first thing you MUST ALWAYS do is switch to the primary site. Otherwise when you attempt the query you will get nothing. Next the widget code calls get_term where the $instance['category'] is a number. This is the number corresponding to the site category term. Last line we call a utility function within the Site Categoriy class that does the query and returns an array of sites complete with avatar is setup.

    So you might also want to take a look at site-categories.php line 506

    Hope this helps.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.