• Resolved Haz

    (@tvguy2000)


    Hi All, I would like to remove “This entry was posted in CAT on DATE by NAME” from my excerpts. I am pretty good with straight forward child themes, but working with the functions.php files is my Achilles Heel.

    I don’t want to use:

    .entry-meta {
        display: none;
    }

    because it just hides the language…not removes it.

    I have a child theme and I would like to use a functions.php in my child theme to eliminate the language all together.

    I need help setting up the contents of the child functions.php file.

    I think the syntax I need to work with is in here:

    if ( ! function_exists( 'twentytwelve_entry_meta' ) ) :
    /**
     * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
     *
     * Create your own twentytwelve_entry_meta() to override in a child theme.
     *
     * @since Twenty Twelve 1.0
     */
    function twentytwelve_entry_meta() {
    	// Translators: used between list items, there is a space after the comma.
    	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    
    	// Translators: used between list items, there is a space after the comma.
    	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    	// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
    	if ( $tag_list ) {
    		$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    		$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} else {
    		$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	}
    
    	printf(
    		$utility_text,
    		$categories_list,
    		$tag_list,
    		$date,
    		$author
    	);
    }
    endif;

    Any help would be sincerely appreciated.

    Thanks!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hi tvguy2000,

    I had the exact same problem and I couldn’t figure it out either, I think I did it the “ass-about” way, but I opened my functions.php file, found the function name, removed all the content within the function and left it blank. So the function name is still being called to wherever, but instead of passing the date and category name etc, it passes “nothing”. I’ve also used display: none; on the elements as a fall-back. It’s not ideal, but it prevents the CSS being manipulated and then allowing the person to place a comment etc.

    Thread Starter Haz

    (@tvguy2000)

    I did sort of the same thing. I went to the parent function.php and found the link of code and deleted what I didn’t want, so that took care of that.

    The issue is what we update the theme, we will have to always go back and do the same thing manually again.

    The better way would be to preserve our changes in a child functions.php, but I can never seem to get it to work without errors.

    Any help from the board would be appreciated.

    John T
    https://www.aquariumcarebasics.com/

    You just need to add your own version of twentytwelve_entry_meta() to your child theme’s functions.php file.

    Thread Starter Haz

    (@tvguy2000)

    Thanks Esmi. Not quite sure how to do that. When I try I always get error messages.

    What are the steps?

    Start by adding:

    <?php
    
    function twentytwelve_entry_meta() {
    	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    
    	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    	if ( $tag_list ) {
    		$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    		$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} else {
    		$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	}
    
    	printf(
    		$utility_text,
    		$categories_list,
    		$tag_list,
    		$date,
    		$author
    	);
    }

    to a completely empty functions.php file in your child theme.

    Thread Starter Haz

    (@tvguy2000)

    Wow, this is a great help.

    So I just copy and paste this into a new functions.php file and put it into the child theme folder? And this file will take priority over the parent functions.php?

    And then I can tweak the language in the child functions.php file?

    Do I have it straight?

    John T

    this file will take priority over the parent functions.php?

    Yes. And you can tweak any/all of the functions in it to your hearts content. ??

    then I can tweak the language in the child functions.php file?

    Sorry? Can you clarify what you mean by “language”?

    Thread Starter Haz

    (@tvguy2000)

    ooops, by “language” I mean remove the words “This entry was posted in…” and the like.

    I will try this out later tonight and let you know how I make out.

    Thanks again for all of your help.

    John T

    I mean remove the words “This entry was posted in…” and the like.

    Yes. The part you need to edit is:

    if ( $tag_list ) {
    		$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    		$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} else {
    		$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	}
    Thread Starter Haz

    (@tvguy2000)

    Thanks a million! It worked!

    Excellent! ??

    I only logged in to say thanks to esmi, this worked beautifully… Not being a programmer but having fooled around with wordpress’ PHP it’s still a moment of magic when things just work…

    Hi,

    I’m trying to remove “This entry was posted in….” text through a functions.php file created in the child theme folder of twentytwelve-child folder. Below is the code of the updated function:

    <?php
    
    function twentytwelve_entry_meta() {
    	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    
    	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    	if ( $tag_list ) {
    		$utility_text = __( '<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    		$utility_text = __( '<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} else {
    		$utility_text = __( '<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	}
    
    	printf(
    		$utility_text,
    		$categories_list,
    		$tag_list,
    		$date,
    		$author
    	);
    }
    ?>

    I tried the above code but it did not remove the text available. I have also tried removing it using “if ( ! function_exists( ‘twentytwelve_entry_meta’ ) )” method but no gain.

    Please help me in getting rid of this text as I do not want this to appear on my category pages below every single post.

    Thanks

    Vikas

    @vikaskukreja

    the code looks ok;

    – are you editing the right file in the right location?
    – do you have the child theme activated?
    – are you using any caching plugins?

    Dear alchymyth

    I just solved this out. I was uploading a different functions.php file on the child theme folder which was empty. I uploaded the correct file and it worked like a charm.

    Thanks

    Vikas

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Twenty Twelve / Remove "This entry was posted in…"’ is closed to new replies.