![]() |
Display first H2 tag as title instead of page title
We have thousands of pages in our site and most of the pages within a section share the same page title, so the search results can look confusing since all the titles on the results page have the same text. Is it possible to get phpdig to display the text in between the h2 tags on the page? since that is a better reflection of the title of the page?
Thanks, -Marc |
Look for the phpdigCleanHtml function in the robot_functions.php file, and in the if-else "//extract title" code snippet, try replacing title with h2 and see if that works.
|
Such as this?
//extracts title if (preg_match('/< *h2 *>(.*?)< *\/ *h2 *>/is',$text,$regs)) { $title = trim($regs[1]); } else { $title = ""; } |
Yes, try that and see if it sets the title to be the content between the h2 tags. BTW, how many h2 tags are there per page? The preg_match will look for the first h2 to match.
|
there are more than 1. I tried it but it picks up the first one, so it works but shows the content for the wrong H2. Is it possible to choose which H2 it picks up?
|
Yep, preg_match matches on the first h2 tag. Try the following instead:
Code:
//extracts title You could also do something like the following: Code:
// assumes there are at least three h2 tags |
All times are GMT -8. The time now is 05:06 PM. |
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.