How to move a Page title but not a Post title for a Genesis child theme

冷暖自知 提交于 2019-12-12 03:44:49

问题


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:

  1. You can use the code in functions.php with a conditional tag like is_singular('page') See this tutorial
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!