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 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统