WordPress.org

Ready to get started?Download WordPress

Forums

search.php 'invents' parent (1 post)

  1. danielle_r
    Member
    Posted 1 year ago #

    Hi all,

    I've got this weird problem. In my child template I use three different colours for different items. Orange = inspiration, Blue = silence, Green = all the rest. Depending on the parent page the logo is displayed in orange, blue or green:

    <?php
    			// check which item
    			$parent_page = get_top_parent_page_id($post->ID);
    			echo "parent: ".$parent_page;
    			if($parent_page == 7){
    			?>
                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/inspiratie_logo.png"  width="146" height="177" alt="" />
    			<?php
    			}
    			elseif($parent_page == 10){
    			?>
                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/stilte_logo.png"  width="146" height="177" alt="" />
    			<?php }
    			else {
    			?>
                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/home_logo.png"  width="146" height="177" alt="" />
                <?php
    			}
    			echo "</a>";
    			?>

    This works fine for all items. But the search results page should have green logo, but after my upgrade to 3.5.1. just now it seems to take a random parent but never green any more. The search form looks like this:

    <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ));?>">
    		<label for="s" class="assistive-text"><?php _e( 'Search', 'twentyeleven' ); ?></label>
    		<input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Zoek|Search', 'twentyeleven' ); ?>" />
    		<input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'twentyeleven' ); ?>" />
    	</form>

    On the website: http://www.awarenesslab.nl you can see that I print the parent. Why is the parent set to either 10 of 7 even when I search from the homepage which has 5 as a parent? And more inportantly, what can I do to make this right again?
    Thanks ever so much in advance for your help, best, danielle.

Topic Closed

This topic has been closed to new replies.

About this Topic