Widget to display post data

If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

Sometimes it is necessary to write widget that will display post data for an associated single post or page. Lets say a map associated with some custom fields on a post.

This snippet should help, this is an example and just part of the widget code, see http://codex.wordpress.org/Widgets_API on the full Widget experience

	 * Front-end display of widget.
	 * @see WP_Widget::widget()
	 * @param array $args     Widget arguments.
	 * @param array $instance Saved values from database.
	public function widget( $args, $instance ) {
	    if (is_single()) {
		echo $args['before_widget'];
		global $post;
		echo the_ID();
		echo $args['after_widget'];







Leave a Reply

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