Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

ablewebs on "Increase number of recent posts in Activity widget on Dashboard"

$
0
0

Hi,

I am customizing the Dashboard and I need to show more than 5 recent posts in the Activity widget. Below is a solution that looked promising, but it didn't work. I added it to Custom > Functions in Dynamik Website Builder. Any help would really be appreciated.

I did find a plugin, but it did way, way more than I need. http://codecanyon.net/item/advanced-activity-widget/1525794?s_phrase=advanced%20activity&s_rank=1

Link to my client's site: http://www.balanceanddizziness.org.

// unregister the default activity widget
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
function remove_dashboard_widgets() {

    global $wp_meta_boxes;
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);

}

// register your custom activity widget
add_action('wp_dashboard_setup', 'add_custom_dashboard_activity' );
function add_custom_dashboard_activity() {
    wp_add_dashboard_widget('custom_dashboard_activity', 'Activity', 'custom_wp_dashboard_site_activity');
}

function custom_wp_dashboard_site_activity() {

    echo '<div id="activity-widget">';

    $future_posts = wp_dashboard_recent_posts( array(
        'display' => 7,
        'max'     => 15,
        'status'  => 'future',
        'order'   => 'ASC',
        'title'   => __( 'Publishing Soon' ),
        'id'      => 'future-posts',
    ) );

    $recent_posts = wp_dashboard_recent_posts( array(
        'display' => 7,
        'max'     => 15,
        'status'  => 'publish',
        'order'   => 'DESC',
        'title'   => __( 'Recently Published' ),
        'id'      => 'published-posts',
    ) );

    $recent_comments = wp_dashboard_recent_comments( 10 );

    if ( !$future_posts && !$recent_posts && !$recent_comments ) {
        echo '<div class="no-activity">';
        echo '<p class="smiley"></p>';
        echo '<p>' . __( 'No activity yet!' ) . '</p>';
        echo '</div>';
    }

    echo '</div>';

}

Viewing all articles
Browse latest Browse all 8245

Trending Articles