[Support request] meta for cpt

Home Forums Support [Support request] meta for cpt

Home Forums Support meta for cpt

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #243846

    using a litle snipplet to show meta of cpts:

    if ( ! function_exists( 'generate_post_meta' ) ) :
     * Build the post meta
     * @since 1.3.29
    add_action( 'generate_after_entry_title', 'generate_post_meta' );
    function generate_post_meta()
    	if ( 'post' == get_post_type() || 'band' == get_post_type() ) : ?>
    		<div class="entry-meta">
    			<?php generate_posted_on(); ?>
    		</div><!-- .entry-meta -->
    	<?php endif;

    this adds the date as expected… two questions:
    1. what is the way to srtrip down the date so it only shows the year?
    2. how can i also add the taxonomy of the cpt with this?

    thanks in advance ๐Ÿ™‚

    Lead Developer
    Lead Developer

    It uses the get_the_date() function which I believe pulls the format from “Settings > General.

    Not sure what you mean about adding your taxonomy?


    1. … jep. but the intention was to strip don the date only for the cpt. (normal post should keep their full date format)

    2. same way as adding the ‘posted_on’ meta for cpt – only adding taxonomy/category for cpt to show on frontend. struggling wit this, because gp blog settings dont take effect for cpt… ๐Ÿ™‚

    more clear?

    Lead Developer
    Lead Developer

    1. You would have to overwrite the generate_posted_on() function, and then adjust the get_the_date() function meet your needs: https://codex.wordpress.org/Function_Reference/get_the_date

    2. Ah, you would overwrite this function: https://github.com/tomusborne/GeneratePress/blob/1.3.40/inc/template-tags.php#L751-L767

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