Reputation: 1400
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();
Upvotes: 2
Views: 3044
Reputation: 1
add_filter( 'wp_title', 'wp_title_so_18381106', 10, 3 );
It did not work for me. I fixed the problem by using the following:
<?php
require '../wp-blog-header.php';
add_filter('pre_get_document_title', 'change_the_title');
function change_the_title() {
return "The title that I'm looking for";
}
get_header();
echo "Here is the content!";
get_footer();
?>
Upvotes: 0
Reputation: 1
Just below require add the code like:
require '../wp-blog-header.php';
add_filter( 'wp_title', 'wp_title_so_18381106', 10, 3 );
function wp_title_so_18381106( $title, $sep, $seplocation ) {
return 'Embeded WordPress | ';
}
And this will work!
Note: You'll need to add the separator and space, otherwise the thing will join with your site title.
Upvotes: 0
Reputation: 26055
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?
Upvotes: 4
Reputation: 5183
add_filter( 'wp_title', 'title_you_want',10);
function title_you_want(){
return "my custom title";
}
Upvotes: 0