Add content above featured pages

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.

68 thoughts on “Add content above featured pages”

Comments are closed.