• Resolved aichandmokie

    (@aichandmokie)


    Hello.

    I have a similar problem to this topic: https://www.ads-software.com/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)
  • could try is_page(‘$id’) instead of is_front_page

    Thread Starter aichandmokie

    (@aichandmokie)

    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?

    Try <li id="om"><a <?php if ( is_home() )

    Thread Starter aichandmokie

    (@aichandmokie)

    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

    (@aichandmokie)

    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.