• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Add Widget Before Loop On First Page of Front Page or Posts Page

Here’s 4 code snippets you can use to create a widget which only displays on the first page of your front page or home page (posts page).

You can use either your front page or a custom blog page as your posts page using the Reading Settings.

This PHP code simply registers a new widget which displays before your blog posts loop on the front page of your site.

The content of your widget will only display on the first page and not on paginated pages.

Note: All PHP code needs to be copied from the view raw link and pasted at the end of your child themes functions.php file.

You can use this code when use these Reading Settings:

default reading settings

Note: You can also use the is_home() conditional tag in replace of the is_front_page conditional tag when using the default Reading Settings to display posts on your front page.

Custom Blog Page – Not Front Page

If you have created a static page for your front page and using another page with the blog page template, use this code instead.

This code works when your Reading Settings look like this:

reading settings

Note: If you use front page displays latest posts, this code will not display the widget before your loop on a custom blog page.

It will display the widget content on your front page.

Learn more about Using Conditional Tags For Home, Front & Blog Pages

Alternative Method

This method uses get_query_var which enables you to further customize where you want your widget to display.

Other Themes

This code should work with any theme as it uses a WordPress hook. Tested on both Twenty Eleven default theme for WordPress and Genesis 2.0 Sample child theme running HTML 5.

Clarification Of Using is_home() Conditional Tag

Note: Use of the is_home() conditional tag depends on your Reading Settings.

If your Reading Settings are set to: Front page displays > Your latest posts, then the is_home() conditional tag will return true for your front page.

If your Reading Settings are set to: Front page displays > A static page (select below) , then the is_home() conditional tag will return true for your blog page and not your Front Page.

  • Show Blog Page Title On 1st Page Only
  • Show Shortcode Content Before Posts On Home Page Only

Reader Interactions

Comments

  1. Zimbrul says

    September 26, 2013 at 12:10 am

    This is by far the most educative site for Genesis framework users. I’m going to implement some of your tips & tricks and let me know if I can be of any help to you in exchange for the great tutorials on your website.

    Log in to Reply
    • Brad Dalton says

      September 26, 2013 at 12:11 am

      No worries. Let me know if you get stuck.

      Log in to Reply
  2. Zimbrul says

    September 25, 2013 at 10:08 pm

    That’s why I love Genesis: it’s a modular framework that lets you add bits of code here to enable things and lets you un-register things you don’t need.
    Thanks Brad for all your tutorials, they are really good and I think one day day you could put everything into a book about customizing Genesis.

    Log in to Reply
    • Brad Dalton says

      September 25, 2013 at 11:00 pm

      hahaha. Feel like i’ve already written a few books already but its a good idea.

      Me too with Genesis. Just gets better and better.

      Working on some really good posts at the moment so more to come very soon.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.