Home Forums Support Hooks

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #47394
    David Seibel

    I’m pretty new to all this….

    I added a video using hooks but just want to show it on the homepage. I put it in the content container and it (obviously) show up on all pages. My homepage is not a static page. I can see doing this on other pages if it is possible.

    Since I’m just getting my feet wet with html, the more detail the better!

    Thanks

    #47410
    Tom
    Lead Developer
    Lead Developer

    Hi David,

    To add things to specific pages, we’ll need to use some PHP.

    If your homepage is a blog, then we can do this:

    <?php if ( is_home() ) : ?>
          Your hook contents in here that should only show up on your blog
    <?php endif; ?>

    Then make sure you check the “Execute PHP” checkbox, and you should be good to go 🙂

    Let me know if you need more detail.

    #47412
    Dave Seibel

    Tom,

    Thanks. That worked. Can I assume that to do this in any other page I can just replace the is_home() with is_pagename()?

    Thanks again,

    Dave

    #47413
    Tom
    Lead Developer
    Lead Developer

    Almost, each page has what’s called a “slug”.

    For example, the “slug” of the knowledgebase on this site is “knowledgebase”, which is the name after the .com.

    http://generatepress.com/knowledgebase/

    So if I want to target something on that page, I would do this:

    <?php if ( is_page( 'knowledgebase' ) ) : ?>
          This will show up on the knowledgebase
    <?php endif; ?>

    Another example: http://generatepress.com/addons/

    <?php if ( is_page( 'addons' ) ) : ?>
          This will show up on the addons page
    <?php endif; ?>

    You can learn more about the WordPress conditionals here: http://codex.wordpress.org/Conditional_Tags

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.