Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Header configuration & styling (http://forum.bytesforall.com/forumdisplay.php?f=15)
-   -   Best way to Append Page Template <Title> Dynamically (http://forum.bytesforall.com/showthread.php?t=19811)

IILLC Mar 4, 2013 08:43 PM

Best way to Append Page Template <Title> Dynamically
 
I have a database driven template in my website and would like to add an item name to the beginning of the page title.

Would it be better to try to add and concatenate the page title and title tag or can I just replace the info sent to with a custom string?

Atahualpa Code

PHP Code:

<?php 
list($bfa_ata$cols$left_col$left_col2$right_col$right_col2$bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header(); 
extract($bfa_ata); 
?>

I am not 100% sure how it handles the generation but was hoping I could add my variable before the list and then just replace the $bfa_ata['h_posttitle'].

My Thoughts

PHP Code:

<?php
$itemname 
=  $row_rsMainItemListing['Name'];
$pagetitle "$itemname - Dungeons and Dragons Online Item Info";
list(
$bfa_ata$cols$left_col$left_col2$right_col$right_col2$bfa_ata['h_blogtitle'], $pagetitle) = bfa_get_options();
get_header(); 
extract($bfa_ata); 
?>

Or am I totally off base?

Thanks a ton for your help!

juggledad Mar 5, 2013 04:30 AM

the page title is built in the code bfa_meta_tags.php. You would have to edit that code and put your title override in there and remember to save the change and redo it each upgrade

you might try searching for a plugin.

IILLC Mar 5, 2013 03:39 PM

Is there anyway to do this at the template level? I want to change the template, not how all titles are processed.

juggledad Mar 5, 2013 05:05 PM

The issue is that the templates call get_header() which runs header.php which builds the begining of the page and that calls the code in bfa_meta_tags.php where the actual <title....> is built. So, no you can't do it in the template as far as I can see.

You'll have to put in logic to check the page I'd to then do what you want.

IILLC Mar 5, 2013 06:24 PM

Thank you for the clarification. There was an article I saw today that spoke about how Google uses the first instance of a <title> if there are more than one. So I implemented a gimpy work around to see what happens in the index.

So I am placing this code in front of the generation.
PHP Code:

<title> <?php echo $row_rsMainItemListing['Name']; ?> | Item Details | Dungeons and Dragons Online</title>
<meta name="description" content="<?php echo $row_rsMainItemListing['Name']; ?> item details. On Dungeons and Dragons Online Magic Item Info page you'll find all the info of a rare Dungeons and Dragons magic items."/>

It appears to be sort of working to start with.

Right now the pages are not indexed and I suspect it is because they appear to be duplicate content to Google. If this works to get them indexed by having an accurate <title> in lieu of a code error (2 <title> with one out of the <head>) I can work with that.

However, I am not sure yet what kind of unforeseen issues this might cause in this template.

IILLC Mar 5, 2013 08:03 PM

What about the option of removing get_header(); and then manually building it for this page on the template? What kind of horrors would I unleash on the theme and plugins if I did that?

I appreciate the help as I learn how all of these theme pieces work together.

juggledad Mar 6, 2013 04:26 AM

the best way to learn is to try it.


All times are GMT -6. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.