dongmo3413 2013-08-22 12:55
浏览 52
已采纳

Wordpress标题外部php文件 - 更改标题?

i have an external php file which i m loading the wordpress header and footer into which works fine but does anyone have any ideas how you can change the page title?

/* Short and sweet */
define('WP_USE_THEMES', false);
require('/home/reboot/public_html/wp-blog-header.php');

// get wordpress header
get_header();
  • 写回答

4条回答 默认 最新

  • doubi7496 2013-08-22 13:02
    关注

    Applying wp_title filter in the file works for me:

    define( 'WP_USE_THEMES', false );
    require( $_SERVER['DOCUMENT_ROOT'] .'/wp-load.php' );
    
    add_filter( 'wp_title', 'wp_title_so_18381106', 10, 3 );
    
    function wp_title_so_18381106( $title, $sep, $seplocation ) {
        return 'Embeded WordPress';
    }
    
    // get wordpress header
    get_header();
    

    See: What is the constant WP_USE_THEMES for? and What is the correct way to use wordpress functions outside wordpress files?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改