Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1274622
    Ying-Fu Li
    Participant

    Hi,

    I have added this code to the function.php of a new site:

    add_action('x_after_site_begin', function(){
    ?>
    
    <!-- your TEXT/HTML content here -->
    <!-- Example Start -->
    <div class="my_top_section">
    <img src="" />
    <h2><i class="fa-icon-chevron-right"></i> PERSOONLIJKE VERKOOP VOOR ZZP'ERS <i class="fa-icon-chevron-left"></i></h2>
    </div>
    <style>
    h2, .h2 {
     margin: 0.25em 0 0;
     }
    .my_top_section {
    text-align: center;
    background-color: #ffffff;
    height: 125px;
    border-bottom: 2px solid #e2001a;
    }
    </style>
    <!-- Example End -->
    
    <?php
    });

    Now I want this only to be shown on the homepage. How do I do that?

    Thanks!

    #1274638
    Thai
    Moderator

    Hi There,

    Please try with this code instead:

    add_action('x_after_site_begin', function(){
    	if(is_home()){
    	?>
    
    	<!-- your TEXT/HTML content here -->
    	<!-- Example Start -->
    	<div class="my_top_section">
    	<img src="" />
    	<h2><i class="fa-icon-chevron-right"></i> PERSOONLIJKE VERKOOP VOOR ZZP'ERS <i class="fa-icon-chevron-left"></i></h2>
    	</div>
    	<style>
    	h2, .h2 {
    	 margin: 0.25em 0 0;
    	 }
    	.my_top_section {
    	text-align: center;
    	background-color: #ffffff;
    	height: 125px;
    	border-bottom: 2px solid #e2001a;
    	}
    	</style>
    	<!-- Example End -->
    
    	<?php
    	}
    });

    If it doesn’t work, please replace is_home() with is_front_page()

    Cheers!

    #1274728
    Ying-Fu Li
    Participant

    Thanks. ‘is_front_page()’ did the trick.

    #1274733
    Thai
    Moderator

    You’re most welcome 🙂

  • <script> jQuery(function($){ $("#no-reply-1274622 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>