Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi pcuniverse,

    This can be done, but it’s not available by default.

    What I mean is that you can create a plugin for it.

    I’m also unsure why you would want it to automatically change? This can result in a “spammy” page.

    Nevertheless, I’ve create an (untested!) example snippet of a new filter which I still need to document, it should work from The SEO Framework 2.6.0 and later:

    add_filter( 'the_seo_framework_pro_add_title', 'my_special_title_conditions', 10, 3 );
    function my_special_title_conditions( $title, $args = array(), $escape = true ) {
    
    	if ( is_singular() ) {
    		$post = get_post( $args['term_id'] );
    		//* Get the author by ID, or guess...
    		$author = isset( $post->post_author ) ? get_the_author_meta( 'user_nicename', $post->post_author ) : get_the_author_meta( 'user_nicename' );
    	} else {
    		$author = 'Default Author';
    	}
    
    	$changes = array(
    		'%year%' => date( 'Y' ),
    		'%month%' => date( 'F' ),
    		'%id%' => $args['term_id'], // term_id holds all IDs
    		'%something%' => 'Else',
    		'%author%' => $author,
    	);
    
    	if ( $args['taxonomy'] ) {
    		//* On a taxonomy or term.
    		foreach ( $changes as $key => $out ) {
    			if ( false !== strpos( $title, $key ) )
    				$title = str_replace( $key, $out, $title );
    			continue;
    		}
    	}
    
    	if ( ! $escape && ! $args['escape'] ) {
    		//* Let's escape it if it's not going to be otherwise.
    		$title = esc_attr( $title );
    	}
    
    	return $title;
    }

    I hope this helps :).

Viewing 1 replies (of 1 total)
  • The topic ‘Output date and month in description/title’ is closed to new replies.