mindblowin
Regular Member
- Aug 6, 2010
- 260
- 49
Smart hack
Appreciate the share
Appreciate the share
/ * Активировать функцию шорткода в заголовке сообщения * /
add_filter ('the_title', 'do_shortcode');
/ * Активировать функцию шорткода в заголовке и мета-описании Yoast * /
add_filter ('wpseo_title', 'do_shortcode');
add_filter ('wpseo_metadesc', 'do_shortcode');
/ * Шорткод для отображения текущего месяца и года в WordPress * /
/ * короткий код: [month_year] * /
add_shortcode ('month_year', 'current_month_year');
function current_month_year () {
$ year = дата ("Y");
$ месяц = дата ("М");
возврат "$ месяц $ год";
}
/ * Шорткод для отображения текущего года в WordPress * /
/ * шорткод: [год] * /
add_shortcode ('year', 'current_year');
function current_year () {
$ year = дата ("Y");
возврат "$ year";
}
[/КОД]
[CODE] / * шорткод для отображения текущего месяца и года в WordPress * /
/ * шорткод: [long_month_year] * /
add_shortcode ('long_month_year', 'current_long_month_year');
function current_long_month_year () {
$ year = дата ("Y");
$ месяц = дата ("F");
return "$ month, $ year";
}[/КОД]
Для отображения полного месяца и года теперь вы можете использовать [B][COLOR=rgb(128, 255, 0)]шорткод [long_month_year] в[/COLOR][/B] любом месте статьи.
Ура! :)
Armur [/ QUOTE]
[B][COLOR=#b30000][SIZE=5]Как это сделать для SEOPress?[/SIZE][/COLOR][/B]
Try changing the second last line from return "$year" ; to:
Code:return "[$year]";
That should change the output of [year] shortcode to [2020]. So you can simply type title [year] to get title [2020]
I haven't tried this code though. Typing this from my mobile now. Do try and let me know if it works.
Cheers!
Armur
Thank @armur for great Tips, but I am using rankmath not yoast seo, how to use code
Seems to work great. However of one the things I have noticed was that, I were already using enclosing brackets around the year ("[2020]") and I wasn't able to keep it with the brackets. Do you know any workaround?
Basically I am looking to get "title [2020]" and not "title 2020". "title [[year]]" did appear as "title [[year]]".
Any suggestions?
Yes, it's definitely very effective on Review/Affiliate sites, not so much for e-commerce sites.This method is really good for review sites or affiliate sites but not if you are competing with big players.
Still useful