Title: Adding widget shortcode to php file
Last modified: August 20, 2016

---

# Adding widget shortcode to php file

 *  Resolved [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/)
 * Todd – you had helped me set up the alignment for your widget on my previous 
   question, so I was thinking you might be able to help me with this question as
   well?
 * So here is my new page with your plugin looking the way I wanted it to…
    [http://www.newlifebiblestudies.org/unlearnedandignorantmen/](http://www.newlifebiblestudies.org/unlearnedandignorantmen/)
 * What I’m wondering is, is there a way to get this same sidebar to show up in 
   my category page? Here is an example category page…
    [http://www.newlifebiblestudies.org/category/unlearned/proverbs/](http://www.newlifebiblestudies.org/category/unlearned/proverbs/)
 * Basically, I want the same look and feel as the other page. I am assuming there
   is a way to add the shortcode for your widget into my archives.php file? If not
   no big deal, I was just hoping to keep the site consistent if I could. Thanks
   in advance for all your help!
 * Jake
 * [http://wordpress.org/extend/plugins/widgets-on-pages/](http://wordpress.org/extend/plugins/widgets-on-pages/)

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

 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394114)
 * Also, I would only want to do this if I could keep it category specific (since
   we have three different blogs on this site that are being sorted out by three
   parent categories)… if you could let me know if that’s possible, I would appreciate
   it as well. Thanks!
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394359)
 * Hey Jake,
 * This could be done by using the Widget on Pages template tag. See step (5) of
   the [installation instructions](http://wordpress.org/extend/plugins/widgets-on-pages/installation/).
   As for making the categories specific this might need a tweak to the widget itself
   to becomes aware.
 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394376)
 * Oh thanks I didn’t see that there in the installation! I was thinking something
   like this might work for the category specific part…
 * if category = 2
    <?php widgets_on_template(“wop_1”); ?> end if
 * I’m just not sure of the syntax I would need. Would something like that work?
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394377)
 * Yes, that’s right… and you replace the “wop_1” with whatever the sidebar is called(
   as you would specify it in the shortcode).
 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394378)
 * Ok, so I was trying to at least get it to work without categorizing it first,
   and it adds the sidebar correctly based on the css but it doesn’t actually include
   the content that is supposed to be there. See example here – [http://www.newlifebiblestudies.org/category/unlearned/proverbs/](http://www.newlifebiblestudies.org/category/unlearned/proverbs/)
 * This is the code I used… which implements the shortcode I use in my page here–
   [http://www.newlifebiblestudies.org/unlearnedandignorantmen/](http://www.newlifebiblestudies.org/unlearnedandignorantmen/).
 * <?php widgets_on_template(“widgets_on_pages”); ?>
 * Do you see anything else I’m missing?
 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394379)
 * So I have the category specific part working, all I need left is to figure out
   why the widget content is not displaying. Plese let me know if you see anything.
   Here is what I’m using in my archives.php file.
 * <?php if (in_category(‘2’)) : ?>
    <?php widgets_on_template(“widgets_on_pages”);?
   > <?php endif; ?>
 * I appreciate all your help. Thanks,
 * Jake
 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394380)
 * Never mind, I got it all figured out! Thanks very much,
 * Jake
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394381)
 * Great news, Jake… nice work.
 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394385)
 * Thanks! I’m sorry I do have one more related question, then I should be done.
   Do you happen to know what CSS I would use to get the widget sidebar to scroll
   all the way down to the comment box on my post pages? See this link to see what
   it is currently doing.
 * [http://www.newlifebiblestudies.org/unlearned/2013/01/02/sentence-21-proverbs-210/](http://www.newlifebiblestudies.org/unlearned/2013/01/02/sentence-21-proverbs-210/)
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394389)
 * Hey Jake,
 * To do this you could do something like the following;
 * `.one-column section { float: right; width 70%;}`
 * You’d be best then to make the widgets on pages width also a % value so it would
   scale to match (I think your theme is responsive so this would be needed).
 * Obviously play with the values as you see fit.
 * The above would also shift the comment box so not sure that’s exactly what you’re
   after… but you could maybe target the float left with `.excerpt4` perhaps?
 * Ta,
    Todd
 *  Thread Starter [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * (@jnorton1089)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394390)
 * Thanks very much!!!

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

The topic ‘Adding widget shortcode to php file’ is closed to new replies.

 * ![](https://ps.w.org/widgets-on-pages/assets/icon.svg?rev=1400727)
 * [Widgets on Pages](https://wordpress.org/plugins/widgets-on-pages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widgets-on-pages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widgets-on-pages/)
 * [Active Topics](https://wordpress.org/support/plugin/widgets-on-pages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widgets-on-pages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widgets-on-pages/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [jnorton1089](https://wordpress.org/support/users/jnorton1089/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/adding-widget-shortcode-to-php-file/#post-3394390)
 * Status: resolved