Sorry, the forums are locked while I handle some maintenance.

 
This Forum is Currently Locked – Access is Read Only
You must be logged in to post Login


Lost Your Password?

Search Forums:


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

Hide Efficient Related Posts entry in the template's sidebar when there are no related posts

No Tags
UserPost

12:55 pm
March 6, 2010


JD

New Member

posts 1

Hi Aaron thanks for a top plugin.  Its simple to use and does exactly exactly what is expected.  I have set it up to display the list of related posts only in my template's sidebar.  However, I want to hide the generated list's heading when there are no related posts.  I have managed a work-around by using the following code in "sidebar.php".

 

<?php if (!is_front_page() && !is_page()) : ?>
   <li><h2 class="sidebartitle"><?php _e('Related Posts'); ?></h2>
    <ul> <?php wp_related_posts(array('title'=>'', 'num_to_display'=>5)) ?> </ul>
   </li>
<?php endif; ?>

which hides all traces of the plugin from the sidebar if when browsing the site's front page or any other page.  However, the list's heading (ie Relatated Posts) is displayed for posts where there are no related items.  Is there a way to prevent it from being displayed when the list of related posts is empty?  What I am looking for is a conditional statement along the llines of:

$x = "number of related posts";
if (!empty(x)) {display related posts heading and list;}

P.S. I am aware that getting rid of the following is a partial solution:

<li><h2 class="sidebartitle"><?php _e('Related Posts'); ?></h2>

However it  is used display all the headings in the sidebar uniformly so I would like to retain it.

 

Thanks for a superb plugin once again.

Cheers

 

 

No Tags

About the Xavisys Forum

Forum Timezone: America/Phoenix

Most Users Ever Online: 50

Currently Online:
1 Guest

Currently Browsing this Topic:
1 Guest

Forum Stats:

Groups: 3
Forums: 26
Topics: 410
Posts: 1034

Membership:

There are 792 Members
There has been 1 Guest

There are 2 Admins
There is 1 Moderator

Top Posters:

lkmweb@me.com – 9
Brayne – 8
Xarzu – 8
Iain – 8
Aaron Fineman – 8
checox7@yahoo.com – 6

Recent New Members: puckles@gmail.com, kwelx@kwelx.com, kaufmanauthor@gmail.com, meesfrenkelfrank@hotmail.com, heather@holmpage.com, mark@avantgarde-group.nl

Administrators: AaronCampbell (242 Posts), Imported Questions (1 Post)

Moderators: nancy@mequoda.com (0 Posts)



 
Stop Censorship