Add content above featured pages

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

You can search the user’s forum or ask the user community by opening a new thread in the Customizr theme forum. Before opening a new topic, you might want to follow the troubleshooting steps..

Method 1 : with an action hook

This will add a two column block before your featured pages on home.

add_action('__before_main_container' , 'my_content_before_main_container' , 0);
function my_content_before_main_container() {
       if (! is_home() || !is_front_page() )
          return;
	?>
	<div class="container">
		<div class="row-fluid">
			<div class="span6">
				<h2>This is a big title</h2>
			</div>
			<div class="span6">
				<button class="btn btn-primary btn-large">This is a call to action</button>
			</div>
		</div>
		
	</div>
	<?php
}

 

Method 2 : with a filter hook

Add this function in your child theme’s functions.php

add_filter('tc_fp_block_display', 'content_before_fp');
function content_before_fp($html) {
$before_fp = ''; //Put your HTML inside this var
return $before_fp.$html;
}

Your HTML code goes inside the $before_fp var, in between the single quotes. Please note that the HTML you input must have all single quotes escaped with a backslash (example: hell\’s kitchen).

Note that your content will only be displayed if you have the featured pages option active on your homepage. If you want to display content under the slider, instead of featured pages, consider using this snippet.

Note that functions.php is not supposed to be a modified copy of its parent theme counterpart. If unsure, please read about how to create a child theme.

Leave a comment

Your email address will not be published. Required fields are marked *

68 thoughts on “Add content above featured pages”