Title: [Plugin: Widgets on Pages] Code for theme
Last modified: August 19, 2016

---

# [Plugin: Widgets on Pages] Code for theme

 *  Resolved [the masked cat](https://wordpress.org/support/users/iniblogbudi/)
 * (@iniblogbudi)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/)
 * This is a cool plugin. I’ve installed it and love it 🙂
 * But, I have another problem when put the widget to my theme. Is there any chance
   to get the code from widget and put it on theme?
 * Sorry if this an idiot question. Because I am a newbie in php etc.
 * Thank you.
 * [http://wordpress.org/extend/plugins/widgets-on-pages/](http://wordpress.org/extend/plugins/widgets-on-pages/)

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

 *  Thread Starter [the masked cat](https://wordpress.org/support/users/iniblogbudi/)
 * (@iniblogbudi)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1749862)
 * Oops…when I browsed at menu Installation, I found this code:
    `<?php widgets_on_template("
   wop_1"); ?>`
 * But when I applied it in my theme (template), nothing happened. So I tried to
   give a name to WoP sidebar 1 (I give it name: cari) and then I used this code:
   `
   <?php widgets_on_template('cari'); ?>`
 * And it works 🙂
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1749963)
 * Ah great news… sorry you beat me to posting an answer 😉
 * If you like the plugin we’d of course appreciate it if you can rate it also.
 * Ta,
    Todd
 *  Thread Starter [the masked cat](https://wordpress.org/support/users/iniblogbudi/)
 * (@iniblogbudi)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1749976)
 * Of course I did. Five stars 🙂
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1749984)
 * Great, thanks 🙂
 *  [helenebt](https://wordpress.org/support/users/helenebt/)
 * (@helenebt)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750133)
 * Hi Todd,
    I got the plugin in order to add a left sidebar to my theme. I tried
   to add the code <?php widgets_on_template(“wop_1”); ?> to my theme’s “page.php”
   file but it just messed up the entire theme. could you tell me the name of the
   php file I am supposed to put the code in? and if it was the correct php file
   is there something else I am supposed to do? Thanks!
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750136)
 * Hey helenebt,
 * That looks like the right code to add… can you add the rest of your page.php 
   file contents? Also can you confirm what the name of your sidebar is?
 *  [helenebt](https://wordpress.org/support/users/helenebt/)
 * (@helenebt)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750138)
 * Hi Todd,
    I named it leftbar and changed the wop_1 to leftbar in the code then
   added it to the page.php file (didn’t know where, so put it right at the top 
   of the rest of the code.. could be the problem?). I added “my pages” widget to
   that sidebar. It doesn’t end up creating a side bar on my site, but puts my pages
   on the top left corner of the background and pushes the rest of my site off and
   everything looks kind of broken. I am using the Azul theme, in case that info
   makes a difference..
 * Thank you for your reply it is very much appreciated! 🙂
 * here’s the full code for the page.php file:
 *     ```
       <?php get_header(); ?>
   
       		<div id="posts">
   
       			<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
   
       				<div class="post" id="post-<?php the_ID(); ?>">
   
       					<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php edit_post_link('Edit', ' | ', ''); ?></h2>
   
       					<div class="tags">
       						<?php the_tags('Tags: ', ', ', ''); ?>
       					</div>
   
       					<div class="entry">
   
       						<?php the_content(); ?>
   
       						<?php link_pages('<p><strong>Pages:</strong>','</p>','number'); ?>
   
       					</div>
   
       				</div>
   
       			<?php endwhile; ?>
   
       			<?php else : ?>
   
       				<div class="post" id="post-<?php the_ID(); ?>">
       					<h2><?php _e('Not Found'); ?></h2>
       				</div>
   
       			<?php endif; ?>
   
       		</div>
   
       		<?php get_sidebar(); ?>
   
       		<?php get_footer(); ?>
   
       		<?php wp_footer(); ?>
   
       	</div>
   
       </body>
       </html>
       ```
   
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750139)
 * Ah I think it could be the placement of the code in the file… the template tag
   for the widgets on pages needs to go round about where you’d like the widget 
   to appear.
 * In your case you actually want this to create a permanent sidebar right? If this
   is the case you might be best off adding the code to the header.php file as in
   the “flow” of the output this may best suit you.
 * Having looked at the Azul theme you would need to add something like this to 
   your style.css
 *     ```
       .leftbar {
       float:left;
       width: 210px;
       }
       ```
   
 * and also change the width parameter for #posts to 400px instead of 600px.
 * You can further style the .leftbar to remove the bullets and margins/padding 
   etc to make it fit in with the rest of the theme.
 *  [helenebt](https://wordpress.org/support/users/helenebt/)
 * (@helenebt)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750140)
 * yes, I would like to add a permanent sidebar in which I would like to easily 
   move widgets around.. I was hoping your plugin might do it, and it looks like
   it might with a bit of tinkering around with code which I really don’t know much
   of. But I will give your suggestions a try and see what happens 🙂
    Thank you
   for your help!
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750141)
 * No worries… and good luck.
    Feel free to contact me via my site If you need further
   assistance.
 *  [JohannaK](https://wordpress.org/support/users/johannak/)
 * (@johannak)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750156)
 * Hi Todd,
 * I have followed this thread but still not getting it to work within my theme.
 * I named my sidebar rss and changed wop_1 to rss in the code then added it (<?
   php widgets_on_template(“rss”); ?>) to my home.php file (inside the <div class
   =”homepagebox_04″>) but it does not show up. I have tried to add it in multiple
   places within the file, but nothing happens.
 * Hope you can help 🙂
 * Here’s the full code for the home.php file:
 * <?php get_header(); ?>
 * <div id=”contenthome”>
    <div id=”homepagetop”> <?php include(TEMPLATEPATH.”/includes/
   slider.php”);?> </div>
 * <div id=”homepage”>
    <div class=”homepagebox_01″> <div class=”homebox”> <?php
   $recent = new WP_Query(“cat=”.ot_option(‘hp_bottom_cat’).”&showposts=1″); while(
   $recent->have_posts()) : $recent->the_post();?> <?php if( get_post_meta($post-
   >ID, “thumbnail”, true) ): ?> <?php else: ?> <?php endif; ?>
 * 
 * <div class=”homeboxinfo”>
    <h4>” rel=”bookmark”><?php the_title(); ?>
   </h4>
    
   <?php the_excerpt(); ?> </div> <?php endwhile; ?> </div> </div>
 * <div class=”homepagebox_02″>
    <div class=”homebox”> <?php $recent = new WP_Query(“
   cat=”.ot_option(‘hp_bottom_cat’).”&showposts=1&offset=1″); while($recent->have_posts()):
   $recent->the_post();?> <?php if( get_post_meta($post->ID, “thumbnail”, true) ):?
   > <?php else: ?> <?php endif; ?> ” rel=”bookmark”><?php the_post_thumbnail( ‘
   home-thumbnail’ ); ?> <div class=”homeboxinfo”> <h4>” rel=”bookmark”><?php the_title();?
   ></h4> <?php the_excerpt(); ?> </div> <?php endwhile; ?> </div> </div>
 * <div class=”homepagebox_03″>
    <div class=”homebox”> <?php $recent = new WP_Query(“
   cat=”.ot_option(‘hp_bottom_cat’).”&showposts=1&offset=2″); while($recent->have_posts()):
   $recent->the_post();?> <?php if( get_post_meta($post->ID, “thumbnail”, true) ):?
   > <?php else: ?> <?php endif; ?> ” rel=”bookmark”><?php the_post_thumbnail( ‘
   home-thumbnail’ ); ?> <div class=”homeboxinfo”> <h4>” rel=”bookmark”><?php the_title();?
   ></h4> <?php the_excerpt(); ?> </div> <?php endwhile; ?> </div> </div>
 * <div class=”homepagebox_04″>
    <div class=”homebox”> <?php $recent = new WP_Query(“
   cat=”.ot_option(‘hp_bottom_cat’).”&showposts=1&offset=3″); while($recent->have_posts()):
   $recent->the_post();?> <?php if( get_post_meta($post->ID, “thumbnail”, true) ):?
   > <?php else: ?> <?php endif; ?> ” rel=”bookmark”><?php the_post_thumbnail( ‘
   home-thumbnail’ ); ?>
 * <div class=”homeboxinfo”>
    <h4>” rel=”bookmark”><?php the_title(); ?>
   </h4>
    
   <?php the_excerpt(); ?> </div> <?php endwhile; ?> </div> </div> </div> </div>
 * <?php get_footer(); ?>
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750157)
 * Hey JohannaK,
 * In your code above I don’t see what I was expecting… from what you said I thought
   i’d see something like the following;
 *     ```
       <div class="homepagebox_04">
       <?php widgets_on_template("rss"); ?>
       <div class="homebox">
       <?php $recent = new WP_Query("cat=".ot_option('hp_bottom_cat')."&showposts=1&offset=3"); while($recent->have_posts()) : $recent->the_post();?>
       <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
       <?php else: ?>
       <?php endif; ?>
       " rel="bookmark"><?php the_post_thumbnail( 'home-thumbnail' ); ?>
   
       <div class="homeboxinfo">
       <h4>" rel="bookmark"><?php the_title(); ?></h4>
       <?php the_excerpt(); ?>
       </div>
       <?php endwhile; ?>
       </div>
       </div>
       </div>
       ```
   
 * But actually I don’t see the `<?php widgets_on_template("rss"); ?>` anywhere 
   in there.

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

The topic ‘[Plugin: Widgets on Pages] Code for theme’ 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/)

 * 12 replies
 * 4 participants
 * Last reply from: [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-widgets-on-pages-code-for-theme/#post-1750157)
 * Status: resolved