WordPress.org

Ready to get started?Download WordPress

Forums

Custom meta data (3 posts)

  1. jason_donnini
    Member
    Posted 1 year ago #

    I am wanting to customize whether the meta data for the date and author is being added per post. The solution that I implemented is using a tag to remove the information but the tags are still showing. Does anyone know a solution for conditionally showing the tag and author information conditionally on the content-single.php for the twenty eleven theme.

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    The solution that I implemented is using a tag to remove the information

    May you post the code (if it's not too lengthy) that you have tried?

  3. jason_donnini
    Member
    Posted 1 year ago #

    I implemented the same thing in the functions. However this does not edit the meta data for the content-single.php

    if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
    /**
    * Prints HTML with meta information for the current post-date/time and author.
    * Create your own twentyeleven_posted_on to override in a child theme
    *
    * @since Twenty Eleven 1.0
    */
    function twentyeleven_posted_on() {
    if(has_tag('no_date')){
    printf( __( '<span class="meta-sep">Posted by</span> %1$s', 'twentyten' ),
    sprintf( '<span class="author vcard">%3$s</span>',
    get_author_posts_url( get_the_author_meta( 'ID' ) ),
    sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    get_the_author()
    )
    );
    }
    elseif(has_tag('no_author')){
    printf( __( '<span class="sep">Posted on </span><time class="entry-date" datetime="%3$s" pubdate>%4$s</time>', 'twentyeleven' ),
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() )
    );
    }
    elseif(has_tag('no_author_date')){
    printf( __( '', 'twentyeleven' ),
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() )
    );

Topic Closed

This topic has been closed to new replies.

About this Topic