We're merging with GenerateBlocks! Learn more here.

[Support request] Show Post Category Next to Date

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Show Post Category Next to Date

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16762
    Connor
    Participant

    Hi there!

    I am wondering if it is possible to show the post category next to the post date. Ideally, what I am looking for is something like “May 17, 2020 | Budgeting.” I would also like to make it so the date is not a link if possible.

    Thank you, Tom!

    Best,

    Connor

    #16767
    Connor
    Participant

    Hi there!

    I was able to get the category next to the date with the built-in option. To remove the link from the date I added:

    add_filter( 'wpsp_date_output', 'tu_wpsp_updated_date_first' );
    function tu_wpsp_updated_date_first() {
    	$time_string = '';
    	
    	$time_string .= '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
    	
    	$time_string = sprintf( $time_string,
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_attr( get_the_modified_date( 'c' ) ),
    		esc_html( get_the_modified_date() )
    	);
    	
    	// If our date is enabled, show it
    	$output = sprintf(
    		'<span class="wp-show-posts-posted-on wp-show-posts-meta">
    			%1$s
    		</span>',
    		$time_string
    	);
    
    	return $output;
    	
    }

    This does work (though I am not sure if the PHP is done right, as I was copying code from the forum and then modifying to take out the modified date part.

    Thanks!

    #16806
    Tom
    Keymaster

    That looks perfect – thanks for sharing the solution 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.