0

I am trying to figure out if it is possible to add elements to the widgetpage in WordPress' dashboard without editing the widgets.php core file. Is there a WordPress function or something else (maybe even a jQuery solution) that will get this done?

If I google this the only results are about widget area's but I just need to add an image (like really an img element, not a widget) to the widget page.

Is there anyone that knows if this is possible and give me some hint/help.

1

You can use @kudratullah's suggestion to hook into the widgets page. The downside is that this allows insertion of a piece of html only in one specific place. If that location is ok, use that solution.

Otherwise, there are two other possibilities.

The first is to use jquery. Examine the source to identify the html element where you want to add your image (let's say #wrap). Then append the node like this:

$( "#wrap" ).append( "<img src='....' />" );

The second is to use the css after pseudoclass like this:

#wrap:after {content:url('/path/to/mypic.jpg');}

Both style and script files need to be enqueued to the admin.

0

There is few action hooks in wp-admin/widgets.php you need to check. And if you want to add a image in Widgets page i would recommend to use widgets_admin_page action hook. This hook fires right after Widgets page title and alert messages are print.

add_action( "widgets_admin_page", "add_image_after_widget_page_title" );
function add_image_after_widget_page_title() {
    echo '<img src="path to your image" alt="">';
}
  • 1
    Thanks! This works really good if you want your image to display under the title. In the end I used the jQuery solution from cjbj to have a little more control about where to show it. But thanks! :) – Maartje Jan 19 '17 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.