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条)

报告相同问题?

悬赏问题

  • ¥15 请问各位,如何在Jetson nano主控板的Ubuntu系统中安装PyQt5
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致
  • ¥150 求 《小魔指》街机游戏机整合模拟软件