web-dev-qa-db-fra.com

Remplacer les widgets du tableau de bord par une bannière publicitaire

Je sais que ce n'est probablement pas encourageant, mais existe-t-il un moyen de remplacer les widgets de tableau de bord standard (Brouillons récents, Quickpress, etc.) par une bannière publicitaire standard?

Je sais comment ajouter de nouveaux widgets de tableau de bord, mais je veux que ce soit une image simple, sans widget environnant.

1
Dean Elliott

Vérifiez cette référence

http://www.wpbeginner.com/wp-themes/how-to-add-custom-dashboard-widgets-in-wordpress/

pour ajouter un widget de tableau de bord

Supprimer les widgets dans le tableau de bord

pour supprimer un widget de tableau de bord

add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );
function example_remove_dashboard_widgets() {
    remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );

    remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
    wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');
}
function custom_dashboard_help() {
    echo 'Your custom banner code';
    }
3
Mohit Bumb
// Add & Remove meta boxes
function wpse50413_alter_dashboard_widgets()
{
    // For details on removing widgets, see answer by @janw
    remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );

    // @link http://codex.wordpress.org/Function_Reference/add_meta_box
    add_meta_box( 'dashboard_ad_widget', 'Your Ad Title here', 'wpse50413_add_adbox', null, 'dashboard' );
}
add_action( 'wp_dashboard_setup', 'wpse50413_alter_dashboard_widgets' );

// The callback function, that defines the ad
function wpse50413_add_adbox()
{
    // display add here - this is the ad boxes contents
}
3
kaiser

Tout ce que vous devez savoir est ici:
http://codex.wordpress.org/Dashboard_Widgets_API#Examples

supprimez tous les widgets de tableau de bord standard:
dans functions.php

<?php
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );
function example_remove_dashboard_widgets() {
    remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );

    remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
}
1
janw