Title: Active button for home.php
Last modified: August 19, 2016

---

# Active button for home.php

 *  Resolved [aichandmokie](https://wordpress.org/support/users/aichandmokie/)
 * (@aichandmokie)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/)
 * Hello.
 * I have a similar problem to this topic: [http://wordpress.org/support/topic/264319?replies=10](http://wordpress.org/support/topic/264319?replies=10)
   but it doesn’t give me a solution I can use. So therefore I created a new topic.
 * Here’s my problem:
    I can’t get my “Frontpage” button in my footer to show active
   when I’m on my frontpage. Instead the button for a category is showing active.
 * I have createad a home.php page that works as my static frontpage (Without choosing
   static frontpage in the control panel). This home.php shows the recent post in
   two different categories.
 * I have two other buttons which only opens posts if is_category.
 * How to get the buttons to reckognise the frontpage as
    `<?php echo get_option('
   home'); ?>`
 * I have figured out that the footer shows the category button active because the
   last post on home.php is from that particular category. Do not have the problem
   in my header buttons…
 * This is how I have coded in the recent posts in my home.php:
 *     ```
       <div id="forsideinnhold">
   
                   <div class="presse">
   
                      <h4>Ferskeste presseoppslag</h4>
       <ul>
   
       <?php //begin the loop, show my recent posts, some of this code will have to be changed to match your theme, ie. the date postion
       query_posts('cat=3&posts_per_page=6');
       if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <li><a href="<?php the_permalink() ?>" title="Link til <?php the_title(); ?>"><?php the_title(); ?><br />
       <span class="date"><?php the_time('j. F Y') ?></span></a></li>
       <?php endwhile; else: ?>
       <p><?php _e('Sorry, no posts.'); ?></p>
       <?php endif; //end the loop, we are done grabbing posts ?>
   
       </ul>
   
                       </div>
   
                   	<div class="artikler">
   
       <h4>Ferskeste fagartikler</h4>
       <ul>
   
       <?php //begin the loop, show my recent posts, some of this code will have to be changed to match your theme, ie. the date postion
       query_posts('cat=4&posts_per_page=3');
       if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <div class="exe">
       <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Les innlegget <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
       	<?php the_excerpt(); ?>
       <div class="time">Lagt ut den <strong><?php the_time('j. F Y') ?></strong> og skrevet av <strong><?php the_author(); ?>.</strong>
       			<br /><?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('Ingen kommentar »', '1 kommentar »', '% kommentarer »'); ?></div></div>
       <?php endwhile; else: ?>
       <p><?php _e('Sorry, no posts.'); ?></p>
       <?php endif; //end the loop, we are done grabbing posts ?>
   
       </ul>
   
                       </div>
   
                   </div>
       ```
   
 * And my footer buttons is coded like this:
 *     ```
       <div class="footnav">
   
       				<ol>
   
       					<li id="forside"><a <?php if ( is_front_page() ) { ?> class="active"<?php } ?> href="<?php echo get_option('home'); ?>/index.php" title="Forsiden"></a></li>
   
       					<li id="fag"><a <?php if ( is_category('fagartikler') ) { ?> class="active"<?php } ?> href="<?php echo get_option('home'); ?>/fagartikler" title="Fagartikler"></a></li>
   
       					<li id="presse"><a <?php if ( is_category('presse') ) { ?> class="active"<?php } ?> href="<?php echo get_option('home'); ?>/presse" title="Presseomtale"></a></li>
   
                           <li id="analyse"><a <?php if ( is_page(2) ) { ?> class="active"<?php } ?> href="<?php echo get_option('home'); ?>/?page_id=2" title="Bestill en analyse"></a></li>
   
       <li id="om"><a <?php if ( is_page(10) ) { ?> class="active"<?php } ?> href="<?php echo get_option('home'); ?>/?page_id=10" title="Om Sosioraster"></a></li>
   
       				</ol>
   
                       </div>
       ```
   
 * Anyone have the time to help me?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [gerbilk](https://wordpress.org/support/users/gerbilk/)
 * (@gerbilk)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/#post-1306137)
 * could try is_page(‘$id’) instead of is_front_page
 *  Thread Starter [aichandmokie](https://wordpress.org/support/users/aichandmokie/)
 * (@aichandmokie)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/#post-1306249)
 * That did not work.
 * Maybe because my front page doesn’t have an ID…?
 * Is there something I could code in beneath the recent post in my home.php to 
   avoid the category button to show active?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/#post-1306250)
 * Try `<li id="om"><a <?php if ( is_home() )`
 *  Thread Starter [aichandmokie](https://wordpress.org/support/users/aichandmokie/)
 * (@aichandmokie)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/#post-1306251)
 * > Is there something I could code in beneath the recent post in my home.php to
   > avoid the category button to show active?
 * Figured this one out, with this code.
 * `<?php wp_reset_query(); ?>`
 * But I still can’t get my frontpage button to show active when I’m on my frontpage.
 * Tried is_home
 *  Thread Starter [aichandmokie](https://wordpress.org/support/users/aichandmokie/)
 * (@aichandmokie)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/#post-1306252)
 * Cool!
 * When using
    `<?php wp_reset_query(); ?>`
 * after
 * `<?php endif; ?>`
 * it fixed so that is_home now works on my frontpage button. !
 * Cool – thanks for the help peepz.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Active button for home.php’ is closed to new replies.

## Tags

 * [home](https://wordpress.org/support/topic-tag/home/)
 * [index](https://wordpress.org/support/topic-tag/index/)
 * [is_category](https://wordpress.org/support/topic-tag/is_category/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [aichandmokie](https://wordpress.org/support/users/aichandmokie/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/active-button-for-homephp/#post-1306252)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
