Gaurav Tiwari
Forum Replies Created
-
And yes, SEO redirect for logged-out users is disabled.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Year change only after annual event heldThis is a very specific use case @paulryken .
You can use this into your child theme’s functions.php or Code Snippets plugin.
add_shortcode('specialdate', 'dmyip_rmd_specialdate');
function dmyip_rmd_specialdate($atts) {
// Set default attributes and merge with user input
$attributes = shortcode_atts(array(
'floor_date' => 'today',
'ceiling_date' => 'last sunday of january next year'
), $atts);
// Parse the floor date using strtotime
$floor_date = strtotime($attributes['floor_date']);
if (!$floor_date) {
return ''; // Clear any error messages
}
// Parse the ceiling date using strtotime
$ceiling_date = strtotime($attributes['ceiling_date']);
if (!$ceiling_date) {
return ''; // Clear any error messages
}
// Calculate the ceiling date next year
$ceiling_date_next_year = strtotime('+1 year', $floor_date);
// Get today's date
$today = time();
// Determine if today's date is between the floor date and the ceiling date next year
if ($today >= $floor_date && $today <= $ceiling_date_next_year) {
// Format the ceiling date with day, month, and year
$display_date = date_i18n('j F Y', $ceiling_date);
return esc_html($display_date);
}
return '';
}
add_shortcode('specialyear', 'dmyip_rmd_specialyear');
function dmyip_rmd_specialyear($atts) {
// Set default attributes and merge with user input
$attributes = shortcode_atts(array(
'floor_date' => 'today',
'ceiling_date' => 'last sunday of january next year'
), $atts);
// Parse the floor date using strtotime
$floor_date = strtotime($attributes['floor_date']);
if (!$floor_date) {
return ''; // Clear any error messages
}
// Parse the ceiling date using strtotime
$ceiling_date = strtotime($attributes['ceiling_date']);
if (!$ceiling_date) {
return ''; // Clear any error messages
}
// Calculate the ceiling date next year
$ceiling_date_next_year = strtotime('+1 year', $floor_date);
// Get today's date
$today = time();
// Determine if today's date is between the floor date and the ceiling date next year
if ($today >= $floor_date && $today <= $ceiling_date_next_year) {
// Format the ceiling date to show just the year
$display_year = date_i18n('Y', $ceiling_date);
return esc_html($display_year);
}
return '';
}It has two components.
[specialdate ceiling_date="last sunday of january next year"]
will show the full date like 28 January 2025.[specialyear ceiling_date="last sunday of january next year"]
will just show 2025.
In the ceiling_date argument you can ask for dates in natural language.Let me know if this works.
I will be adding this to the plugin as well but only after someone else asks for it.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Previous year in search resultsYes, it happens. I haven’t done anything out of the box with the plugin. It is totally native, so if there is a cache solution available, the dates will be cached for performance.
Glad that it got fixed automagically.
Always feel free to create a new topic if you need any other assistance.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Previous year in search results<?php the_title(‘<h2 class=”blog-post-title h5″>’, ‘</h2>’); ?>
This code is totally fine and the plugin should render well. Are you sure that you are not seeing a Cached version?Feel free to send URLs in questions in a private message, so that I can check on this.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] WPBakery footerHi, this has nothing to do with WPBakery. The Nominee theme doesn’t support shortcodes in footer. You should ask the theme support for a resolution on this. Maybe they will have something like {current_year} to render the current year in footer.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Not with current yearCheers, glad to know that.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Not working on LinkedInHi @samanthadixon, as Benjamin told SEOPress doesn’t have out of box support for shortcodes in JSON feed used by LinkedIn. You can get in touch with SEOPress team to get a workaround.
Or, do you want me to dig deeper and offer you a fix?
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Work with Simple SEO?I have been using Rank Math for years. You can always disable modules from their Dashboard panel, if you want and the speed won’t be compromised. Other than that I can suggest SEOPress.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Work with Simple SEO?Hi, I checked. The plugin author strips shortcode content and hasn’t offered any filters that could work to enable my plugin’s content.
You can always use other SEO plugins which are more optimized and have better developer support.
Forum: Plugins
In reply to: [Dynamic Month & Year into Posts] Work with Simple SEO?I haven’t completely tested it with Simple SEO. Will surely do and ensure that it works.
It’s been my pleasure. Be sure to open a new thread if something else occurs. All Shortcodes are listed here: https://gauravtiwari.org/snippet/dynamic-month-year/#shortcodes
In the code on the right side first line – php code, who write category name.
Can you share the exact code, please?
Edit: I see that has been fixed too. ?? Well done.
- This reply was modified 9 months ago by Gaurav Tiwari.
Can you try changing the
if (get_field('category_short_name', 'category_'.$terms->term_id)) { $cat_title = get_field('category_short_name', 'category_'.$terms->term_id); } else { $cat_title = $terms->name; }
with:
if (get_field('category_short_name', 'category_'.$terms->term_id)) { $cat_title = do_shortcode(get_field('category_short_name', 'category_'.$terms->term_id)); } else { $cat_title = do_shortcode($terms->name); }
(This is in //crumbs part.)
I see. Can you please share the PHP code for the Breadcrumb and also that of Table of Contents that you have on right?
Hi @buldog52, I have released an update. Please update to 1.3.6 and let me know how this works for you.