Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Header configuration & styling »

Best way to Append Page Template <Title> Dynamically


  #1  
Old Mar 4, 2013, 08:43 PM
IILLC
 
7 posts · Feb 2013
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!
  #2  
Old Mar 5, 2013, 04:30 AM
juggledad's Avatar
juggledad
 
23,628 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Mar 5, 2013, 03:39 PM
IILLC
 
7 posts · Feb 2013
Is there anyway to do this at the template level? I want to change the template, not how all titles are processed.
  #4  
Old Mar 5, 2013, 05:05 PM
juggledad's Avatar
juggledad
 
23,628 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Mar 5, 2013, 06:24 PM
IILLC
 
7 posts · Feb 2013
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.
  #6  
Old Mar 5, 2013, 08:03 PM
IILLC
 
7 posts · Feb 2013
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.
  #7  
Old Mar 6, 2013, 04:26 AM
juggledad's Avatar
juggledad
 
23,628 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
the best way to learn is to try it.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks

Tags
dynamic, page title, php, template

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display page title in custom page template beetle8 Atahualpa 3 Wordpress theme 7 Oct 22, 2012 07:28 AM
Changing page content dynamically chrisrap Center area post/pages 1 Aug 29, 2011 05:12 AM
How can I adjust a div height dynamically ? dinoc Center area post/pages 7 Dec 21, 2010 07:05 AM
in Title Bar: possible to append a blurb or tag line? petevannuys Header configuration & styling 1 Jun 29, 2009 07:21 PM


All times are GMT -6. The time now is 10:19 AM.


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