Reputation: 25
I have a wordpress theme running the "static" side of my website (www.url.com/home), and I'm working outside of it for the App (www.url.com/app), but I'm using the wordpress header and footer in the App so as to mantain the look and feel.
The problem is that all pages in the /app directory are coded as a 404 Error. I can somewhat solve this using js to change the title of the page once the page loads, but that isn't a good solution (all search engines ignore those pages).
The wordpress part defines the title like this:
<?php
if ( is_plugin_inactive('wordpress-seo/wp-seo.php') ) {
bloginfo( 'name' );
}
?>
<?php
wp_title("|", true);
?>
I'm not very good with PHP. Can anyone offer a solution so that the title is set normally within the wordpress environment, but instead of automatically tagging the website as an error it will check if the url address starts with "url.com/app" and if it does, it will just title the page something ("Web app", for example).
Thanks, and sorry if the question is lame but I'm really new with PHP.
Upvotes: 1
Views: 51
Reputation: 515
The correct way is to add a filter into your functions.php file within your theme. So:
wp-content/themes/[YOUR THEME]/functions.php
Add this to the end and then just change the "Your Page Title Here" string. It will add a filter and change any pages that include "/app" in the URI.
function set_title_if_slash_app( $title ){
$full_url = $_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
if (strpos($full_url,"/app") !== false) {
return "Your Page Title Here";
}
return __( 'Home', 'theme_domain' ) . ' | ' . get_bloginfo( 'description' );
}
add_filter( 'wp_title', 'set_title_if_slash_app');
Upvotes: 1