This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Can a default template use an HTML element from a custom template page?

  • Creator
    Topic
  • #26021
    noto
    Member

    Is there a way to add an HTML element below the header and above the page template?

    I’m using the “post grid template” for a blog and I basically want to place an HTML element (header graphic and title) that I have on my custom template pages on top of the Blog. When I add the graphic using the “featured image” and the page title copy. The size of the image and the treatment of the text doesn’t match my other HTML element. It would be easiest to insert that same HTML element at the top of the post grid template page. Can this be done?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #26023
    Jason Bobich
    Keymaster

    Hi,

    As far as end-user features, you could put HTML in the WordPress content of the page and I believe it’ll display above the post grid, but this probably won’t be exactly what you want. Alternatively, you could create a custom widget area at Appearance > Widget Areas, apply it to the “Ads Above Content” location and assign it the specific pages you want. Then from Appearance > Widgets add a Text widget to that custom widget area you created with your HTML.

    But reading more into what you’re describing, I have a feeling if you’re not familiar with the basics of WordPress action hooks, that this is something you’ll want to dive into. The theme framework is filled with tons of action hooks that fire in different places. You can hook to them from your child theme’s functions.php, to output whatever you want.

    Here’s a map of them:

    http://dev.themeblvd.com/tutorial/primary-framework-action-hooks/

    And WordPress has tons of conditional functions you can use to determine the current page:

    https://codex.wordpress.org/Conditional_Tags

    So for example:

    function my_content_top() {
        if ( is_page_template('template_grid.php') ) {
            echo '<div class="foo">This is some HTML...</div>';
        }
    }
    add_action('themeblvd_content_top', 'my_content_top');
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.