• Resolved Rick

    (@rferrall)


    I have a child theme for twenty seventeen. I’m trying to remove the author link first, then need to move the date to the bottom of the post. However, I’ve created inc/template-tags.php in the child theme, but it’s not overriding the parent.

    I’ve tried turning $byline = “”; under twentyseventeen_posted_on() and tried removing $byline from the echo command, but it’s still showing the admin name & link.

    Can we not use inc/ in child themes, or am I missing something?

    I don’t simply want to hide the author reference, I would like it gone from the template.

    Thanks.

    • This topic was modified 7 years, 11 months ago by Rick. Reason: clarification
Viewing 7 replies - 1 through 7 (of 7 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The files inside of the ‘inc’ folder are not templates and cannot be overridden by using the technique to override a template. You need to look at the function you want to override, find where it’s called in the parent theme and go from there. Once you’re at that stage I can help you.

    Thread Starter Rick

    (@rferrall)

    Oh, can I just pop the modified version in the functions.php in the child theme, then? The function is twentyseventeen_posted_on() called from template-parts/post/content.php line 26 in latest versions.

    Full text is this:

    function twentyseventeen_posted_on() {
    
    	// Get the author name; wrap it in a link.
    	$byline = sprintf(
    		/* translators: %s: post author */
    		__( 'by %s', 'twentyseventeen' ),
    		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . get_the_author() . '</a></span>'
    	);
    
    	// Finally, let's write all of this to the page.
    	echo '<span class="posted-on">' . twentyseventeen_time_link() . '</span><span class="byline"> ' . $byline . '</span>';
    }
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Which file was this in?

    Thread Starter Rick

    (@rferrall)

    The function is in twentyseventeen/inc/template-tags.php, starting on line 12.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I found it, template-tags.php.

    So, yes you can copy the function and paste it into your Child Theme functions.php file because it has this bit of code:

    
    
    if ( ! function_exists( 'twentyseventeen_posted_on' ) ) :
    
    ...
    

    If it didn’t have that conditional statement then your site would break.

    Thread Starter Rick

    (@rferrall)

    Ok, thank you very much for your help.

    I would love just remove the link, because the URL is showing the actual user name, instead of the display name, to any hacker that happens by and I find that much less than secure. I would also be happy with showing the display name in the URL.
    Is there a simple way to do either of these in the child site? Perhaps if I change ID to ??
    Thanks so much
    M

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Remove author link with child theme’ is closed to new replies.