multisite - Display site description instead of site name

I'm wondering how to display all the network sites in WP Multisite by displaying site description instead of site n

I'm wondering how to display all the network sites in WP Multisite by displaying site description instead of site name. Below is the code provided by the expert in WP in this community. It's now displaying site name. What code should I change in order to make the list displaying all the sites with site description?

function wpse365255_print_sites() {
    $args = array(
        'number' => 10000, // if you've got more than 10,000 sites, 
                           //you can increase this
        'public'        => 1,
        'spam'          => 0,
        'deleted'       => 0,
        'archived'      => 0,
        'site__not_in'  => array( 1, 2 ), 
        // this will exclude sites with ID 1 and 2
    );
    $sites = get_sites( $args ); // will return an array of WP_Site objects 
    $list = '';
    foreach ( $sites as $site ) {
        $details = get_blog_details( $site->blog_id );
        if ( ! empty( $details ) ) {
            $list .= '<li>';
            $list .= '<a href="' . $details->siteurl . '">';
            $list .= $details->blogname;
            $list .= '</a>';
            $list .= '</li>';
        }
    }
    if ( ! empty( $list ) ) {
        echo '<ul>' . $list . '</ul>';
    }
}

I tried to change the blogname to blogdescription but the site description not showing up. I look forward to answers from the experts here. Thank you!

I'm wondering how to display all the network sites in WP Multisite by displaying site description instead of site name. Below is the code provided by the expert in WP in this community. It's now displaying site name. What code should I change in order to make the list displaying all the sites with site description?

function wpse365255_print_sites() {
    $args = array(
        'number' => 10000, // if you've got more than 10,000 sites, 
                           //you can increase this
        'public'        => 1,
        'spam'          => 0,
        'deleted'       => 0,
        'archived'      => 0,
        'site__not_in'  => array( 1, 2 ), 
        // this will exclude sites with ID 1 and 2
    );
    $sites = get_sites( $args ); // will return an array of WP_Site objects 
    $list = '';
    foreach ( $sites as $site ) {
        $details = get_blog_details( $site->blog_id );
        if ( ! empty( $details ) ) {
            $list .= '<li>';
            $list .= '<a href="' . $details->siteurl . '">';
            $list .= $details->blogname;
            $list .= '</a>';
            $list .= '</li>';
        }
    }
    if ( ! empty( $list ) ) {
        echo '<ul>' . $list . '</ul>';
    }
}

I tried to change the blogname to blogdescription but the site description not showing up. I look forward to answers from the experts here. Thank you!

Share Improve this question edited May 8, 2020 at 7:41 Jornes asked May 8, 2020 at 6:55 JornesJornes 7535 gold badges12 silver badges31 bronze badges 1
  • You may try changing $details->blogname to get_blog_option( $site->blog_id, 'blogdescription') – 西門 正 Code Guy - JingCodeGuy Commented May 8, 2020 at 10:03
Add a comment  | 

1 Answer 1

Reset to default 2

get_blog_option() return blog info by supplying blog id and blog option name. So you may try changing the blog name variable from

$details->blogname to get_blog_option( $site->blog_id, 'blogdescription')

in the loop

Becauae get_blog_details() does not add the description from option to its output object. So it let is needed to manually fetch additional information.

By default, the get_blog_details() only returns the following details of the site

  • blogname
  • siteurl
  • post_count
  • home

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744486738a4576605.html

相关推荐

  • multisite - Display site description instead of site name

    I'm wondering how to display all the network sites in WP Multisite by displaying site description instead of site n

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信