• Hi,
    I am working on a site where I need to add a <div> with some content in it at the top of each static page.

    The <div> should be one color on some pages and another on other pages.
    The CSS works fine, but my code doesn’t…it just adds both the divs on all pages except the frontpage.

    I have this code so far:

    <?php if( !is_front_page() ) { //if we are not on the front page ?>
    
    	<div class="row">
               	if(is_page('ydelser-2'))
    		{
    			<div class="hidden-phone top_box">
    				We will add content here
    			</div>
    		} ?>
    
    		elseif(is_page('blog-2'))
    		{
    			<div class="hidden-phone top_box_blog">
    				We will add more content here
    		     	</div>
    		} ?>
    	</div>
    
    <?php } ?>

    Can anyone solve this riddle for me…?

Viewing 2 replies - 1 through 2 (of 2 total)
  • enable DEBUG while customizing your site: https://codex.www.ads-software.com/Debugging_in_WordPress

    you need to re-open php tags after the html code;

    example:

    <?php if( !is_front_page() ) { //if we are not on the front page ?>
    
    	<div class="row">
               	<?php if(is_page('ydelser-2'))
    		{ ?>
    			<div class="hidden-phone top_box">
    				We will add content here
    			</div>
    		<?php } 
    
    		elseif(is_page('blog-2'))
    		{ ?>
    			<div class="hidden-phone top_box_blog">
    				We will add more content here
    		     	</div>
    		<?php } ?>
    	</div>
    
    <?php } ?>

    Thread Starter bysukro

    (@bysukro)

    Hi alhymyth,
    Thank you ever so much! I will make sure to enable debugging.. It worked perfectly!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add a colored box to the top of each page (that is not the frontpage)’ is closed to new replies.