• Resolved ricky810

    (@ricky810)


    For complicated reasons, I have dd/mm/yyyy in my post names. Not ideal, but have so many I am hoping not to change them at this point. This plugin does everything I could ever want, but wondered if I could do one of two things (appreciate it might end up messing with the plugin files).

    Could I …

    a) trim the name of the post to exclude the date “03/09/1939 – King George VI declared war on Germany” (ignore the bold)

    b) create a custom field and put “King George VI declared war on Germany” in that field and echo that via the plugin, rather than the post title.

    Appreciate this is a niche ask, but any help appreciated. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • This is a pretty specialized use case, so it’s probably not something I would directly code into the plugin, but I could add some custom filters that would allow you to write your own code snippet to modify the title output.

    OK, well… that was a pretty easy change. Version 3.7.0 is available now, with filters added for each of the output elements in the post loop.

    The filter you’d want to use is r34otd_title. I think something like this would work, as long as your titles are consistently using an en dash (I think that’s an en dash?) and that it’s in there as the UTF-8 character and not an ampersand entity:

    add_filter('r34otd_title', function($value, $post_id) {
    if (($pos = strpos($value, '–')) !== false) {
    $value = trim(substr($value, $pos + 1));
    }
    return $value;
    }, 10, 2);

    This is taking the title text string ($value), locating the en dash, and then changing $value to just the part after the en dash.

    This can go in your theme’s functions.php file or somewhere similar.

    Thread Starter ricky810

    (@ricky810)

    This is perfect, thanks ! Implemented and working great.

    I will rate and donate.

    Thanks! I’m glad to hear it’s working for you.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.