Showing and Hiding Sidebar Content in WordPress Blogs

This is just a cool little trick that i thought I’d include for all you WordPress lovers out there.  When it comes to managing a website or blog today at some point you may want to show or hide certain content depending on the page your visitors are on or for some other reason (e.g. “someone purchasing ad space on your website”, etc.).  With WordPress it’s entirely possible to hide certain content on various pages and have that content only appear on specific pages.

So with that understanding, if you want to only show a particular piece of content on the homepage of your WordPress and NOT have this content appear on any other page you can use the following snippet of code…

<?php

if (is_home()) { ;?>

<a href=””>Your link here</a>

<?php } ?>

 

Another option to code content to only show in the front page of your WordPress website is to code using the following snippet of code…

 

<?php

if (is_front_page()) { ;?>

<a href=””>Your link here</a>

<?php } ?>

 

Lastly, if you have content that you only want to show on a certain page (for example the “About” page) then you can use this code snippet…

 

<?php

if (is_page(‘about’)) { ;?>

<a href=””>Your link here</a>

<?php } ?>

Note: keep in mind that the above mentioned code snippets are useable with the standard WordPress functionality.  You’ll need to test to see if they work with your customized WordPress theme to ensure that they work.

Now you can hide certain content on your WordPress website depending on what and where you want to hide it!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This blog is kept spam free by WP-SpamFree.