Skip to main content
added 25 characters in body
Source Link
Mat
  • 1.6k
  • 1
  • 10
  • 17

NB. However, it might be simpler, in this particular case, to just create an empty/blank twentyseventeen_entry_footer() function in your child theme - it just depends whether you would still want this function to work for other post types or post formats (if it's used elsewhere)...

NB. However, it might be simpler, in this particular case, to just create an empty/blank twentyseventeen_entry_footer() function in your child theme - it just depends whether you would still want this function to work for other post types or post formats...

NB. However, it might be simpler, in this particular case, to just create an empty/blank twentyseventeen_entry_footer() function in your child theme - it just depends whether you would still want this function to work for other post types or post formats (if it's used elsewhere)...

Extended answer to explain alternate method
Source Link
Mat
  • 1.6k
  • 1
  • 10
  • 17

If you just wanted toUpdate To remove this category link completely, you do this with a simple template file override.:

On line #24 of the Twenty Seventeen themes single.php file, you should see the following code:

get_template_part( 'template-parts/post/content', get_post_format() );

If you needthen look in the folder referenced in the line above:

/wp-content/themes/twentyseventeen/template-parts/post/

You will see various 'content' PHP files for the various post formats. The default one for normal posts is content.php

Simply copy this file to know howyour child theme within a new folder called in your child theme called /template-parts/post/ and then remove the lines that references the twentyseventeen_entry_footer() function (lines #73-#77):

<?php
if ( is_single() ) {
    twentyseventeen_entry_footer();
}
?>

You can use template overrides for any template files in the parent themes root folder or within the /template-parts/ folder. Simply copy the file to doyour child theme in the same folder structure.

NB. However, it might be simpler, in this particular case, just add a comment to just create an empty/blank twentyseventeen_entry_footer() function in your child theme - it just depends whether you would still want this answer and I can add further instructionsfunction to work for other post types or post formats...

If you just wanted to remove this category link completely, you do this with a simple template file override. If you need to know how to do this, just add a comment to this answer and I can add further instructions.

Update To remove this category link completely with a template override:

On line #24 of the Twenty Seventeen themes single.php file, you should see the following code:

get_template_part( 'template-parts/post/content', get_post_format() );

If you then look in the folder referenced in the line above:

/wp-content/themes/twentyseventeen/template-parts/post/

You will see various 'content' PHP files for the various post formats. The default one for normal posts is content.php

Simply copy this file to your child theme within a new folder called in your child theme called /template-parts/post/ and then remove the lines that references the twentyseventeen_entry_footer() function (lines #73-#77):

<?php
if ( is_single() ) {
    twentyseventeen_entry_footer();
}
?>

You can use template overrides for any template files in the parent themes root folder or within the /template-parts/ folder. Simply copy the file to your child theme in the same folder structure.

NB. However, it might be simpler, in this particular case, to just create an empty/blank twentyseventeen_entry_footer() function in your child theme - it just depends whether you would still want this function to work for other post types or post formats...

Source Link
Mat
  • 1.6k
  • 1
  • 10
  • 17

The category link that you are referring to, that is displayed beneath the single post page content is not added with a filter. It is displayed via a function called twentyseventeen_entry_footer().

If you take a look at the themes files you can find the function on line #59, within the file:

/wp-content/themes/twentyseventeen/inc/template-tags.php

Here is the twentyseventeen_entry_footer() functions code:

if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) :
    /**
     * Prints HTML with meta information for the categories, tags and comments.
     */
    function twentyseventeen_entry_footer() {

        /* translators: used between list items, there is a space after the comma */
        $separate_meta = __( ', ', 'twentyseventeen' );

        // Get Categories for posts.
        $categories_list = get_the_category_list( $separate_meta );

        // Get Tags for posts.
        $tags_list = get_the_tag_list( '', $separate_meta );

        // We don't want to output .entry-footer if it will be empty, so make sure its not.
        if ( ( ( twentyseventeen_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) {

            echo '<footer class="entry-footer">';

            if ( 'post' === get_post_type() ) {
                if ( ( $categories_list && twentyseventeen_categorized_blog() ) || $tags_list ) {
                    echo '<span class="cat-tags-links">';

                        // Make sure there's more than one category before displaying.
                    if ( $categories_list && twentyseventeen_categorized_blog() ) {
                        echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
                    }

                    if ( $tags_list && ! is_wp_error( $tags_list ) ) {
                        echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
                    }

                    echo '</span>';
                }
            }

            twentyseventeen_edit_link();

            echo '</footer> <!-- .entry-footer -->';
        }
    }
endif;

As you should see from the original function code, the first line is:

if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) :

So, if the function already exists the code in the parent theme will be ignored. Due to the way WordPress works, it loads the child themes functions.php file first, before the parent theme.

In order to modify this code you would copy or create your own twentyseventeen_entry_footer() function within your child themes functions.php file (without the function_exists() line, and without the final endif; line).

Therefore, by creating the twentyseventeen_entry_footer() function within your child theme, this will override the default functionality of the parent themes function.

If you just wanted to remove this category link completely, you do this with a simple template file override. If you need to know how to do this, just add a comment to this answer and I can add further instructions.