• Anonymous User 17976131

    (@anonymized-17976131)


    I’m a bit lost. I’ve got an archive.php and it’s using the_archive_title(). It’s showing On This Day but, as expected for today because I’ve no prior posts on this day, nothing. But how do I access the various customization options?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author room34

    (@room34)

    Customization options appear within the widget configuration.

    Thread Starter Anonymous User 17976131

    (@anonymized-17976131)

    Right. I was asking if that means that you can’t customize the way it appears on archive.php.

    Plugin Author room34

    (@room34)

    I apologize… I was being a bit dense. (Or, I didn’t read the title of the thread, just the message itself.)

    I was thinking you were talking about your theme’s archive.php file, not the one in the plugin.

    There’s not a way to directly modify this in the plugin, but the plugin is using a hook to customize the title, so you could extend it a bit further.

    Right now the plugin is using closures (anonymous functions) for its hook modifications. I should really change that. Anyway, I think you should be able to alter the title with this:

    
    add_filter('get_the_archive_title', function($title) {
    	if (strpos($title,'On This Day') === 0) {
    		$title = 'YOUR MODIFIED TITLE HERE';
    	}
    	return $title;
    }, 11, 1);
    

    This is going to hijack the modification the plugin makes and make a further alteration to it. You may need extra code if you want to pull in anything dynamic like the date.

    Here’s the code that’s in the plugin itself, in archive.php lines 42-55:

    
    // Change archive title
    add_filter('get_the_archive_title', function($title) {
    	global $wp_query;
    	if ($wp_query->is_main_query() && get_query_var('r34otdarchive')) {
    		if ($r34otddate = get_query_var('r34otddate')) {
    			$date = strtotime(substr($r34otddate,0,2) . '/' . substr($r34otddate,2,2) . date('Y'));
    		}
    		else {
    			$date = current_time('timestamp');
    		}
    		$title = _('On This Day') . ': ' . date('F j', $date);
    	}
    	return $title;
    });
    

    Don’t modify this directly in the plugin because it will get overwritten when the plugin is updated.

    • This reply was modified 4 years, 9 months ago by room34.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Customizing the ‘Optional On This Day archive page”?’ is closed to new replies.