Title: Different Widget Every Single Post
Last modified: August 30, 2016

---

# Different Widget Every Single Post

 *  Resolved [mbguru](https://wordpress.org/support/users/mbguru/)
 * (@mbguru)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/)
 * Hi,
    I am after a solution to display a different widget on every single post.
   The site will have hundreds of posts as it’s being run as a diary/blog format,
   so I am after a solution bearing this in mind.
 * I’ve tried to implement Custom Fields alongside PHP Code Widget.
    In the PHP 
   Code Widget Sidebar propety i’ve the following code:
 *     ```
       <?php
       if ( is_single() ) :
            global $post;
            if ( get_post_meta( $post->ID, 'per_post_content', true ) ) :
                 echo get_post_meta( $post->ID, 'per_post_content', true );
            endif;
            wp_reset_postdata();
       endif
       ```
   
 * On every Post, I’ve got a Custom Field named ‘per_post_content’ and inside their
   I’ve been inserting my WP Widget Shortcode for example;
 * `[wp_progress_bar text="Progress" text_color="#fff" background="#eee" progress_color
   ="#bbb" pc="90" width="100%" bottom="15px"]`
 * The widget is just blank and not displaying anything, and I am unsure if the 
   code is wrong, or what’s the best solution to get this working.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383560)
 * First; let’s make sure the code is working properly.
 *     ```
       if ( is_single() ) :
            global $post;
            if ( get_post_meta( $post->ID, 'per_post_content', true ) ) :
                 echo 'TESTING';
            endif;
            wp_reset_postdata();
       endif;
       ```
   
 * Does that display the word “TESTING” in the widget area?
 *  Thread Starter [mbguru](https://wordpress.org/support/users/mbguru/)
 * (@mbguru)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383561)
 * Hi Josh,
    Yes inserting this code into PHP Code widget outputs the word TESTING
   in Widget Area
 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383621)
 * Okay.. now let’s wrap the shortcode in a [do_shortcode()](https://developer.wordpress.org/reference/functions/do_shortcode/)
   function.
 *     ```
       if ( is_single() ) :
            global $post;
            if ( get_post_meta( $post->ID, 'per_post_content', true ) ) :
                 $shortcode = get_post_meta( $post->ID, 'per_post_content', true );
                 echo do_shortcode( $shortcode );
            endif;
            wp_reset_postdata();
       endif;
       ```
   
 *  Thread Starter [mbguru](https://wordpress.org/support/users/mbguru/)
 * (@mbguru)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383660)
 * Sorry to sound daft, the code you attached above, am i right in saying that goes
   into the PHP Code Sidebar Widget
 * And do i then in my “per_post_content” insert the following value;
 * `do_shortcode([wp_progress_bar text="Progress" text_color="#fff" background="#
   eee" progress_color="#bbb" pc="90" width="100%" bottom="15px"])`
 * Or am i missing something here?
 *  Thread Starter [mbguru](https://wordpress.org/support/users/mbguru/)
 * (@mbguru)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383661)
 * Scrap that last reply, I’ve just inserted the Code you sent above into my PHP
   Code widget however it needed the opening:
    `<?php`
 * Once i’d inserted this and then in my per_post_content I added:
    `[wp_progress_bar
   text="Progress" text_color="#fff" background="#eee" progress_color="#bbb" pc="
   90" width="100%" bottom="15px"]`
 * It’s now working just perfect!
 * Thanks Josh you’re a star!
 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383669)
 * My pleasure. Glad you got it working.
 * Yes, sorry… you need the opening `<?php`.
    You’ve got it, good job.
 * You are very welcome 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Different Widget Every Single Post’ is closed to new replies.

## Tags

 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [Josh](https://wordpress.org/support/users/josh401/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/different-widget-every-single-post/#post-6383669)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
