how to control display switch_to_blog( $subsite->blog_id ); $tags = wp_tag_cloud

using get_sites I managed to display a list of WP Multisite Subsites with a variety of data pulled from the sites. However I cannot control where the tags are being displayed — instead of showing up within the html elements, a tag cloud is displayed above the page content

/** get sites */

function make_list_shortcode()
{
$subsites = get_sites (
[‘number’ => 500, ‘orderby’ => ‘last_updated’, ‘order’ => ‘DESC’, ]);
if (!empty($subsites))
{
$html = ‘<ul >’;
foreach($subsites as $subsite)
{
$subsite_id = $subsite->blog_id;
$subsite_name = get_blog_details($subsite_id)->blogname;
$subsite_link = get_blog_details($subsite_id)->siteurl;
$subsite_domain = get_blog_details($subsite_id)->domain;
$subsite_path = get_blog_details($subsite_id)->path;

// Switch to Blog
switch_to_blog( $subsite->blog_id );
$site_description = get_bloginfo( ‘description’ );
$logo_image = get_theme_mod( ‘fl-logo-image’ );
$custom_header = get_theme_mod( ‘header_image’ );
$tags = wp_tag_cloud( array( ‘taxonomy’ => ‘category’ ) );

restore_current_blog();
// Added the image tag and src path
$html.= ‘<li style=”list-style: none!important; margin:10px 0; padding:10px; border: 1px solid #ccc;” class=”site-‘ . $subsite_id . ‘” ><a href=”‘ . $subsite_link . ‘” target=”_blank”><img style=”margin-right: 15px;” src=”‘. $logo_image .'” /><img style=”margin-right: 15px;” src=”‘. $the_custom_logo .'” /><img style=”margin-right: 15px;” src=”‘. $custom_header .'” />’ . $subsite_name . ‘</a> ‘ . $site_description . ‘ ‘. $tags .'</li>’;

}

$html.= ‘</ul>’;
return $html;
}
}

add_shortcode(‘list_sites’, ‘make_list_shortcode’);

The result is pulling tags from the subsite but also ignoring $tags in the html element completely.

I also have another question about how to insert an if function exists for the = get_theme_mod in looking for images – different themes use different methods and the way I have it generates 404 errors.

Truly appreciate any help.

Read more here:: blog_id ); $tags = wp_tag_cloud” rel=nofollow>how to control display switch_to_blog( $subsite->blog_id ); $tags = wp_tag_cloud

Leave a Reply

Your email address will not be published. Required fields are marked *