[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.
https://www.ads-software.com/extend/plugins/widgets-on-pages/
-
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 ??
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,
ToddOf course I did. Five stars ??
Great, thanks ??
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!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?
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>
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.
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!No worries… and good luck.
Feel free to contact me via my site If you need further assistance.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; ?>” 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_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(); ?>
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.
- The topic ‘[Plugin: Widgets on Pages] Code for theme’ is closed to new replies.