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

add_action( 'after_page_content','custom_title',1); #114

Open bassjobsen opened 10 years ago

bassjobsen commented 10 years ago

Question from @mjteves1986:

I use the add_action( 'after_page_content); on my child themes. The code is perfect. But I have something in my mind, why if I use "before_page_content" is not working, Only "after_page_content" will work. Im planning to create a title page on the top on the content.

This is my code. <?php get_header(); function custom_title() { jbst_page_title(); } add_action( 'after_page_content','custom_title',1);

do_action( 'jbst_before_content_page' ); wp_reset_postdata(); while ( have_posts() ) : the_post(); the_content(); endwhile; do_action( 'jbst_after_content_page' );

get_footer(); ?>

The result of that code is like this: http://screencast.com/t/A5vZQDB8

Is it possible to use a add_action( 'before_page_content','custom_title',1); to make the result insert that title before " .contentwrap #page "? So that the title will be like this? See link: http://screencast.com/t/AeDas11k

For now, Im using jQuery(".contentwrap .page-header").insertBefore(".contentwrap #page"); to get my goal.

bassjobsen commented 10 years ago

Hi Mark,

If i understand you question well, i expect you should be able to use: add_action( 'jbst_header','custom_title',55); to find all action hooks, please take a look at: https://github.com/bassjobsen/Boilerplate-JBST-Child-Theme

Please let me know if the above will help you? If not please tell me why?

I also saw you define a new templates for this. I understand the hooks should work that you can do:

           add_action( 'jbst_header',function(){ if(is_page())echo 'custom title';},55);

Add the above in your template before get_header()

This won't work now cause you will get the title twice. Currently jbst_page_title(); isn't hooked. For the next update i will hook this function too and also create a filter for the page title, so you can do:

           remove_action('jbst_show_page_title' 'jbst_page_title');
           add_action( 'jbst_header',function(){ if(is_page())echo 'custom title';},55);

and / or add_filter('jbst_page_title_html','custom_header');