- This topic has 9 replies, 2 voices, and was last updated 2 years, 2 months ago by David.
-
AuthorPosts
-
November 3, 2021 at 5:39 am #1989565Wendy
Hello, I have a couple of articles that I insert the current date manually.
It’s an annual admin task that I’m sure could be avoided through simple code??? But what??
Here is an example:
https://www.glow-skincare.com/argan-oil-vs-jojoba-oil/
Thank you 🙂
November 3, 2021 at 8:26 am #1990007DavidStaffCustomer SupportHi there,
so are you updating the date only on specific posts ?
Problem with doing it with code, is knowing which posts that change should be applied to and when….let me know
November 4, 2021 at 2:18 am #1990837WendyYes only on a handful of posts, so I would know their page ID?
25979
3585
21978
23857
24910
25486
25672
4751November 4, 2021 at 2:52 am #1990863DavidStaffCustomer SupportYou could use a Shortcode to display the Year in the title – this article explains one method:
https://technumero.com/auto-add-dynamic-year-in-wordpress-post-titles/
Note – that it includes the filter for
do_shortcode
inthe_title
, as well as some filters specifically for Yoast – THIS is important to note if you’re using any SEO plugins or Feeds those too would require filtering.Unfortunately something that seems very simple has several pitfalls….
November 4, 2021 at 3:15 am #1990894WendyOoh yes, that’s perfect now thankyou David. (also for the heads up on SEO plugins or Feeds..)
November 4, 2021 at 3:29 am #1990911DavidStaffCustomer SupportYou’re welcome!
March 14, 2022 at 2:37 am #2153667WendyHello David, hope you are well!
I switched from Yoast to SEOPress on the weekend, and now in MonsterInsights I am seeing strange stuff:
instead of :Bach Flower Remedies List – 2022 Guide
they appear as Bach Flower Remedies List – [year] Guide
The current snippets refer to Yoast: – do I simply change Yoast to SEOPress?
Thank you so much. Current Snippet code pasted below.
//* Shortcode to display the current year in WordPress
//* shortcode: [year]
add_shortcode( ‘year’ , ‘current_year’ );
function current_year() {
$year = date(“Y”);
return “$year”;
}add_filter( ‘the_title’, ‘do_shortcode’ );//* Activate shortcode function in Post Title
add_filter( ‘wpseo_title’, ‘do_shortcode’ );//* Activate shortcode function in Yoast Title
add_filter( ‘wpseo_metadesc’, ‘do_shortcode’ );//* Activate shortcode function in Yoast Meta DescriptionMarch 14, 2022 at 6:01 am #2153898DavidStaffCustomer SupportSo this:
//* Shortcode to display the current year in WordPress //* shortcode: [year] add_shortcode( 'year' , 'current_year' ); function current_year() { $year = date("Y"); return "$year"; } //* Activate shortcode function in Post Title add_filter( 'the_title', 'do_shortcode' );
Is the only code that will work anywhere regardless of what SEO plugin you’re using.
The other two add_filters are 100% yoast specfic ie.
wpseo_title
andwpseo_metadesc
.
You would need to ask SEO Press if they have their own filters for their SEO title and SEO descriptions.
You can share this topic with them so they can see what you need them for.March 14, 2022 at 12:56 pm #2154512WendyThank you David!
I have now switched back to Yoast…it seems better geared up.
March 14, 2022 at 1:02 pm #2154521DavidStaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.