Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7908675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:03:47+00:00 2026-06-03T12:03:47+00:00

I am working on a custom wordpress homepage. I want that it is loading

  • 0

I am working on a custom wordpress homepage.
I want that it is loading in a different div in the header.

The header now loads the #content div for every page. But i want to let it load #contenthome div if the homepage loads.

I’m using this php-code:

<?php if (is_page_template('template-home.php'))  { ?>
<div id="contenthome">
<?php } else { ?>
<div id="content">
<? } ?>

I’m fairly new to php. so i hope you guys can help me 🙂

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:03:49+00:00Added an answer on June 3, 2026 at 12:03 pm

    Or this:

    if(is_home())
    {
        <div id="contenthome">
    <?php } else { ?>
        <div id="content">
    <? } ?>
    

    Personally, I prefer writing things in shorthand when it comes to cases like these. Consider also using this to shorten your code:

    <div id="<?php echo is_home() ? 'contenthome' : 'content'; ?>">
    

    ADDITIONAL NOTES: If your <body> tag has the WordPress body_class() added to it, you can pretty much target individual pages with CSS, even when they’re using the same template. The homepage, like any other page, will have a unique body class applied that will then allow you to target that particular page.

    So if your issue is simply a matter of being able to target any given page regardless of template with CSS, you won’t necessarily NEED to apply any unique divs to your page. For example:

    <style type="text/css">
    #content{display:block;}
    .home #content{display:none;}
    </style>
    

    This will hide the content div only on the homepage. It’s probably not what you want it to do, but you can see how the page itself is being targeted to override the default behavior.

    UPDATE: As per your latest question, if you need another particular page to use that conditional, use is_page() like so:

    LONG CODE:

    if(is_home() || is_page('posts_page_title'))
    {
        <div id="contenthome">
    <?php } else { ?>
        <div id="content">
    <? } ?>
    

    SHORTHAND:

    <div id="<?php echo is_home() || is_page('posts_page_title') ? 'contenthome' : 'content'; ?>">
    

    If you prefer, you may also use is_page(‘posts_page_ID’) or is_page(‘posts_page_slug’). Play around with it and see what works best for you. More information here: http://codex.wordpress.org/Function_Reference/is_page

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

working on a highly complex WordPress theme that features many different custom post types
I am working on a Wordpress-Design and i want to creat a Custom Menu.
I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom
I starting working with WordPress as a CMS, now that the V3 makes it
So, I'm working on a WordPress theme that uses a custom taxonomy to create
I am working on a site that calls the categories of a wordpress page
My wordpress*(a custom template)* nav is all working on all of the pages but
I'm working with wordpress.com along with the custom design upgrade to be able to
I'm working on a blog migration from a custom built blog to Wordpress. One
I have a working custom UserNamePasswordValidator that calls into my Oracle DB. This class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.