• Resolved waynehuang

    (@waynehuang)


    Hi, I am using the Avada theme and trying to figure out how to have a custom header.php for a specific set of pages.

    The default theme layout options don’t allow you to add full-width content in a page that has sidebars enabled. All your content falls into the main body, and I want the content to go above main body and sidebar.

    So far, I have created a custom page template (page-workplaces.php) and referenced a custom header template (header-workplaces.php), and placed both in a child theme.

    From here, I was instructed to

    create a std page in WP and then in the header file using PHP to call that page and it’s content into position: <?php if ( is_front_page() ) { $subPageHeader = new WP_Query("page_id=25″); >while($subPageHeader->have_posts()) : $subPageHeader->the_post(); ?>

    These instructions are incomplete and I need a layman’s explanation of how to achieve this. For example, I don’t understand how to call a page in a php file.

    You can see a mock-up of what I’m trying to achieve here. The four content items: Our Issues, Our Contract, Opportunities, Q&A is what I’m trying to add.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there, I use a plugin that can give you the possibility to have different header images for each post or page… try WP Display Header from the wordpress.org plugins.. there are others, but this one I tested and it works. good luck!

    Hi Wayne. I realize what you try to do. I us a plugin called WP Bakery Visual Composer from Codecanyon. It costs $25 but you could use it on your different websites. This gives you total flexibility to create your own templates, and I us a simple full width theme and adapt that.. try the LINK theme, its free.

    In order to place your custom header on a custom template (a template has a header, content, and a footer and +/- a sidebar) you need the custom template file. It looks like you got that setup with your page-workplaces.php file. Are you using get_header('workplaces')? I assume you are.

    To get the content you use the loop.

    It looks like whoever offered up that advice was trying to pull in a specific page. But, from what I understand, you should be able to use the standard loop in your page-workplaces.php file right before you use get_footer().

    Then you create a normal WP page and select your workspaces template from the dropdown (there’s a templates section). The content from the editor should end up using that custom page template with the custom header, the loop to pull in the content, and the normal footer.

    Look at the codex for is_page()
    You can probably do something like this:

    if ( is_page( 25 ) ) {
    // Display the custom header for this page - using 25 from the original post example. Replace 25 with the page id of the page you need to customize or use an array if multiple pages.
    } else {
    // Display the regular header to be used on all other pages.
    }

    Thread Starter waynehuang

    (@waynehuang)

    Just an update. I found a plugin that does exactly what I needed – https://wordpress.org/plugins/insert-pages/

    Lesson of the day: If you don’t know what you’re doing, there’s probably a plugin out there that does.

    Sounds great!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to have customized header.php for specific page’ is closed to new replies.