Community Forums › Forums › Archived Forums › Design Tips and Tricks › How Do I Change The 'Page Title' On Individual Pages?
Tagged: conditionals, minimum
- This topic has 7 replies, 2 voices, and was last updated 11 years, 4 months ago by richiemerritt.
-
AuthorPosts
-
December 13, 2012 at 4:41 pm #5069richiemerrittMember
Hello!
I was hoping someone could enlighten me with the code to change the Page Title (#page-title) on individual pages.
I'm using the minimum child theme, and I have a blog page and a podcast page (blog category pages), I would like to change the Page Titles on the blog page and the podcast page from the default text: "From The Blog". the website is: http://tattooinsider.comAny information would be awesome. Thank you for your time guys 🙂
♥Richie Merritt
December 13, 2012 at 5:08 pm #5078ramseypMemberHi Richie,
Depending on what you want there, you would have to do some editing of the page-title.php file in the theme (minimum) directory. That file has several conditional statements there that output the #page-title div. What it places in there, depends on the conditional that's triggered. You mentioned two category archives. page-title.php is set to display "From the Blog" on any category, tag, or date archive (along with single posts, search results, or author archives).
Do you want it to not show on those pages or do you want it do something different?
December 13, 2012 at 6:08 pm #5100richiemerrittMemberThank you for your response, ramseyp, I really appreciate it 🙂
Yes, in response to your question, I would like it to do something different.
I have made edits to the page-title.php file before, but tweaking the conditional statements for it to display for individual category archive pages makes me a bit nervous. I've been reluctant to experiment there, as I normally would.So, I would like for the 'podcast' page to display the page title: "From The Podcast" (or something of that nature).
And for the 'blog' page to display: 'From The Blog'.I've had a difficult time trying to find any detailed supporting information on this issue, so your help is very appreciated.
Thanks again.
Richie Merritt
December 13, 2012 at 6:24 pm #5111ramseypMemberHi Richie,
I've got some code in a Gist that should work. Look at that link and you can see where I've added an exclusion in the "From the Blog" conditionals for a single category name. Then after that, I add a conditional just for that one category to output a custom title text for it.
December 13, 2012 at 6:46 pm #5113richiemerrittMemberThank you ramseyp.
I'm reviewing the code and will try to implement this.
Questions...
(Everything seems pretty straight-forward in your instructions, but...)• what is the " && !is_category " ??? Am I supposed to replace the ampersands (&&) with something?
And
• will I need to replicate this code to create an new elseif statement for the 'blog' category page as well, or?
Thank you 🙂
December 13, 2012 at 7:00 pm #5114ramseypMemberHi Ritchie,
What you're seeing there is a combination of conditionals. The double ampersands have to be there so 'my-category' is excluded from the overall is_category() conditional preceding it. The !is_category('my-category') is a negative conditional. So both sides of the double-ampersand mean "if it's a category archive, but not the 'my-category' archive..." I would recommend reading through the Codex page on Conditional Tags so you can see how they're used. It will help, should you have another instance where you need to use them.
As for the blog, it looks like you have a "blog" category, so nothing special needs to be done. When that category is shown, "From the Blog" will be at the top of the page.
December 13, 2012 at 7:32 pm #5119richiemerrittMemberFantastic! Thank you so much for your time and help ramseyp!
I will implement the code, and post a follow up with my results, etc., so others can use this information.
Thanks again.
Richie Merritt
December 13, 2012 at 7:42 pm #5123richiemerrittMemberPerfection!
Implementing the code with instructions you provided worked flawlessly!Thank you so much ramseyp!
I owe you one.Richie Merritt
richiemerritt.com
tattooinsider.com -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.