Welcome! Log In Create A New Profile

Advanced

Dynamic Meta Description

Posted by pinksparklegirl 
Dynamic Meta Description
April 13, 2016 06:39PM
I've just installed Sphider and run into a little problem with the search result descriptions.

My site www.ghostofthedoll.co.uk is php driven and the title and meta tags are created dynamically on each page via the header and the page itself.

The page titles are indexed correctly but the page meta descriptions do not show correctly on the results page. How do I get Sphider to index my meta descriptions? Is is possible to alter the script to point it to the correct place when indexing?

This is my script in the Header page:

<title><?php echo $page_title; ?></title>
<meta http-equiv="description" content="<?php echo $page_description; ?>" />
<meta property="og:image" content="<?php echo $page_image; ?>" />
<meta name="keywords" content="<?php echo $page_keywords; ?>">

This is a sample script of the body of the page:

<?php $page_title = "Alley Kats";?>
<?php $page_description = "Alley Kats were produced by JRL Toys in 1986 and were a small line of plush cats and kittens.";?>
<?php $page_image = "Toys/AlleyKats/Advert1.jpg";?>
<?php $page_keywords = "Alley Kats,JRL,1980's,Plush,Cats,Kittens";?>

Any help or advise would be appreciated.
Tec
Re: Dynamic Meta Description
April 14, 2016 03:22PM
In order to better understand:
Your first code snippet is part of your HTML head tag?
Your second snippet is part of your HTML body tag?
How does your second snippet become meta content?
Something like
<meta MY_TITLE />
Or will it be just a variable injected from PHP into HTML full text?
So it might become something like
<h1> MY_TITLE </h1>

<<< The page titles are indexed correctly but the page meta descriptions do not show correctly >>>
Titles are indexed correctly for head and body tag?
Descriptions are not indexed for head and body tag?

Tec
rap
Re: Dynamic Meta Description
April 16, 2016 04:45PM
Liked Tec, I am a bit confused here. but it LOOKS like you may trying to display variable results before you are even defining the variables.

The <head> section must come before the <body> in html, and <title> must appear within <head>. In your example, your are saying
<php echo $page_title; ?>
then later saying
<php $page_title = "Alley Kats": ?>

I think this may be just improper coding style.

Try something like:
<?php $page_title = "Alley Kats";?>
<?php $page_description = "Alley Kats were produced by JRL Toys in 1986 and were a small line of plush cats and kittens.";?>
<?php $page_image = "Toys/AlleyKats/Advert1.jpg";?>
<?php $page_keywords = "Alley Kats,JRL,1980's,Plush,Cats,Kittens";?>
<php include ("your_header_page.php"winking smiley; ?>
Sorry, only registered users may post in this forum.

Click here to login