bassjobsen / jbst

Powerful theme framework that can be used as a standalone website builder or as a framework to create child themes for wordpress build on Twitter's Bootstrap 3. Full customizable with LESS
http://www.jbst.eu/
GNU General Public License v2.0
96 stars 36 forks source link

Create an action for front-page only #102

Closed bassjobsen closed 10 years ago

bassjobsen commented 10 years ago

Question from @linearis

bassjobsen commented 10 years ago

Hi,

In my opinion you got two option basically: 1) create a home.php or front-page.php in your child theme's folder (see: also http://codex.wordpress.org/Template_Hierarchy and some explanation on http://wordpress.org/support/topic/difference-between-homephp-and-front-pagephp) 2) or use is_home() in your action, see in http://codex.wordpress.org/Function_Reference/is_home

In fact your home.php / front-page.php can be a copy of index.php.

header.php and footer.php describe the hook available for you. Hope this helps? Please let me know if you are missing some hook or if you need an other solution.

ghost commented 10 years ago

I have a front-page.php Because I want to hook before ".jbst-site-wrap" class only on home page, here is what I write in function.php :

function load_slider()
{
    if (is_front_page()) {get_template_part( 'content', 'sliderhome' );}
}   
add_action('jbst_before','load_slider');

EDIT : wrong syntax, I edited the post.

bassjobsen commented 10 years ago

Nice! I think adding all code to functions is a choose you have to made. Alternatively you could all front-page related action in front-page.php. The last spare you an if but on the other hand adds logic to you templates which could make thing more complex than necessarily