Solved

Yoast and Simple Press Titles

Posted on 2014-09-23
10
210 Views
Last Modified: 2014-09-23
All of the page titles on the forum section have the same title - the main title of the forum itself: http://www.sempdx.org/forum/search-specifics/

Using that page as the example, the title is SEMpdx Search Marketing Forum which is the same no matter what your viewing on the forum. What we need it to show for the title is the title you see in the light blue bar which is Search Specifics.

Neither Yoast or Simple Press have a solution for this. They feel that it's picking up the title correctly, which wordpress's wp_title, yes it is, but now we have over a hundred listed pages with that exact same title.

Anyone have any ideas on how to pick up that next title in the blue bar so we have unique page titles? I think even getting the deepest level in the url could be a decent solution as long as the dashes could be replaced with spaces and the first letter of each word capitalized.

Thanks for any help.
Heather
0
Comment
Question by:Dzynit
  • 4
  • 4
  • 2
10 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40339642
Agree with them, whatever plugin you are using for the forums is not setting the page title correctly.
0
 
LVL 14

Author Comment

by:Dzynit
ID: 40339673
Right. But I'm not going to pay for the support membership and continue arguing with the plugin author because the forum there at sempdx is no longer active for new posts. But the forum is staying in place so people can still read previous posts.

That's why I'm thinking the simplest solution would be to grab that last section from the urls and use them as the title. I just need help with some php that would grab that and then convert it into a visually correct title.
Like /search-specifics/ should convert into Search Specifics.

Do you agree something like that would work?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40339689
Not knowing the plugin you could delve into the code, see what variable it is using for the title and use that in the page meta title tag.
0
 
LVL 14

Author Comment

by:Dzynit
ID: 40339711
I tried, but the plugin is so bulky. My customer doesn't want me to spend a pile of time on this either. Simplest solution is the best.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40339831
You can try

$urlparts = explode("/",$_SERVER["REQUEST_URI"]);

$title=ucwords(str_replace("-"," ",$urlparts[count($urlparts)-1]));

Open in new window


And hardcode the $title in the meta tag.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Expert Comment

by:Richard Francis
ID: 40339860
It's not the most optimal solution but you could get the page title from the contents of div with the id spTopicHeaderName. You could then set the page title with jQuery.

Something like:

$(document).ready(function() {

  Var newTitle = $( "#spTopicHeaderName" ).text()
  $(document).prop('title', newTitle);

});

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 40339865
Using javascript search engines et al will still list the original title
0
 
LVL 14

Author Comment

by:Dzynit
ID: 40339873
Thanks Richard, but I was thinking the same thing as Gary. Gary, I'm going to try your suggestion here shortly. I have something else to finish up then I get back to that site and try it out.
0
 
LVL 1

Expert Comment

by:Richard Francis
ID: 40339892
No worries. As I said it wasn't the most optimal solution.
0
 
LVL 14

Author Comment

by:Dzynit
ID: 40339955
Gary, I had to make one edit on the count to -2 because it was counting the trailing slash that's auto added and it works great.

Here's what I used:

to the theme's functions.php
function forumtitle() {
	$urlparts = explode("/",$_SERVER["REQUEST_URI"]);
	$title=ucwords(str_replace("-"," ",$urlparts[count($urlparts)-2]));
	if ($title == 'Forum') { $title = 'SEMpdx Search Marketing Forum'; }
	return $title;
}                                          

Open in new window


In the header.php (id of course being the forum's main page id #)
<title><?php if(get_the_id() == 392) { echo forumtitle(); } else { wp_title(); } ?></title>

Open in new window


Thank you very much!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now