I was wondering if it would be possible to embed an html page or add an iframe into a dashboard widget.

I have a multi author blog and i want to make my admin section a simple as possible for some of my author’s are less “technical”.
So I already added a simple widget containing some text. And I took out the less interesting widgets. And I added some links so they can stay on their dashboard page but be able to do everything they had to do.

But I thought it would also be interesting to embed some sort of comment box so they could like talk to each other and discuss things. something like this
http://www.htmlcommentbox.com

I gives you some html code wich you can paste into your webpage.

So I started to experiment but all the things I tried came out negative. I thought that if I would be able to simply embed it into a widget or embed it on a html page and view it trough an Iframe it could work. But like I said can’t seem to pull it off.

Is it possible? or am I just wasting my time?

1
1

Sure, you can do this. It sounds like it would make more sense to add a protected forum to your installation though… but here’s how you would do it:

// Create the function to output the contents of our Dashboard Widget
function iframe_dashboard_widget_function() {
    // Display whatever it is you want to show
    echo '<iframe src="https://www.htmlcommentbox.com" width="100%" height="300" frameBorder="0">Browser not compatible.</iframe>';
}

// Create the function use in the action hook
function example_add_dashboard_widgets() {
    wp_add_dashboard_widget('iframe_dashboard_widget', 'Iframe Dashboard Widget', 'iframe_dashboard_widget_function');
}

// Hook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );

Leave a Reply

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