There are lots of options on how to insert custom sidebar widget at any page in WP relatively easy. But what about Home page only?
What I needed is just to have something in my sidebar on home page only. Having read and tried numerous complicated solutions I ‘ve found my recipe, which, I believe is the simpliest one:
1. Install this WP plugin exec-php
2. Go to Widgets, put text widget in a sidebar you wish (same works for HTML area in your editor for both posts and pages) and insert piece of conditional tags.
For example to have this <h2>Hello buddy</h2> on home page only, put this piece of code into text widget:
<?php
if(is_home()) { ?>
<h2>Hello buddy</h2>
<?php }
?>
To have it appear on ALL pages except sidebar, add tiny ! to the code:
<?php
if(is_home!()) { ?>
<h2>Hello buddy</h2>
<?php }
?>
It will work for posts, pages, categories etc. To learn more about conditional tags read this StudioPress article. What you need is anything starting with <?php and ending with
?>
Then Exec-php just executes any found php code.






