I have a rotating images widget I want to display on my homepage. My selected homepage is a static front page I created with several other pages to make my blog look more like a website than a blog, and then I have a separate blog page. The widget does not come with shortcode. Rather it comes with something like code that I have to insert in editor in a place that will make the widget appear where I want the rotating images to appear. What I've figured out with trial and error is that when I insert the code into the page.php I can get it to show up exactly where I want it on my selected home page. The problem is that it also shows up on all the other pages except the blog page. So, what I need to do is to write some additional code telling wordpress to only show the widget on the one page. Any ideas on how to write this code?

Here is the code that comes with the widget:

<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>

Thanks, Jason


Try wrapping it with the is_front_page() conditional like so:

<?php if ( is_front_page() ) { include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); } ?>

Hope this helps!


If the gallery widget is a standard widget that you can drag and drop into the sidebar, as opposed to needing the php function to call it, try WordPress › Widget Logic « WordPress Plugins


You can copy page.php to page-{slug}.php and add the code there.


You can try matching against get_the_ID or $post->ID directly. Using an if ... else clause.

if ( get_the_ID() == 12 )
    include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php');

This is not a Widget in the WordPress sense, by the way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.