问题
I asked Studio Press support how to move the page title to a different section of the Genesis framework. They replied with code:
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
add_action( 'genesis_after_header', 'genesis_entry_header_markup_open', 11 );
add_action( 'genesis_after_header', 'genesis_do_post_title', 12 );
add_action( 'genesis_after_header', 'genesis_entry_header_markup_close', 13 );
There's a problem with this, in that it moves both Page titles and Post titles. This means on the Blog page, the Post title is moved into the position of the Page title, and the Post title has the Page title e.g. "News".
My question is: how do I move just the Page title, and not the Post title, using remove_action
/ add_action
...?
Help appreciated.
回答1:
You have 2 choices:
- You can use the code in functions.php with a conditional tag like is_singular('page') See this tutorial
Or add the code to a page.php template file with a opening PHP tag like this:
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); add_action( 'genesis_after_header', 'genesis_entry_header_markup_open', 11 ); add_action( 'genesis_after_header', 'genesis_do_post_title', 12 ); add_action( 'genesis_after_header', 'genesis_entry_header_markup_close', 13 );
genesis();
来源:https://stackoverflow.com/questions/42667841/how-to-move-a-page-title-but-not-a-post-title-for-a-genesis-child-theme