Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Sidebars & Widgets »

Add related php code to sidebar

Prev Previous Post   Next Post Next
Old Sep 19, 2011, 10:13 AM
6 posts · Sep 2011
Add related php code to sidebar


I'd like to use a specific-tag related-post function like the below, but would like to use it in the sidebar. I have no idea how to do that . Would really appreciate your thoughts. I tried clumsily to add it to footer.php, but I don't think that's the right way to do it (and nothing seemed to happen). I looked at the widget tabs in Atahualpa options, but didn't quite understand how all that works. Basically, I'd like to add the following functionality to the right sidebar.

$tags = wp_get_post_tags($post->ID);
  if ($tags) {
  $first_tag = $tags[0]->term_id;
  'tag__in' => array($first_tag),
     'post__not_in' => array($post->ID),

  $rel_posts = new WP_Query($args);
   if( $rel_posts->have_posts() ) {
   while ($rel_posts->have_posts()) : $rel_posts->the_post(); ?>

<div class="rel_posts">
<div class="rel_thumb"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(130,130)); ?></a></div>
<div class="rel_link"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></div> 

<div class="clearer"></div>
Appreciate your time. Thanks a lot.

Last edited by sidejack; Sep 19, 2011 at 10:31 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stuck with php code / left sidebar mikeindidginus Atahualpa 3 Wordpress theme 11 Jun 16, 2011 01:15 AM
Putting Code/Sign Up Form into Sidebar gradlebum Sidebars & Widgets 14 Apr 26, 2010 03:31 PM
how to insert php code into widget or sidebar Stingraynut Header configuration & styling 1 Apr 6, 2010 08:25 PM
[SOLVED] No sidebar.php...where do I put the code? d_random Atahualpa 3 Wordpress theme 0 Apr 3, 2009 12:42 PM
I'm not sure what file I need add code for the sidebar jockoe Atahualpa 3 Wordpress theme 0 Mar 18, 2009 09:45 AM

All times are GMT -6. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.