ColorlibHQ / shapely

Free multipurpose WordPress theme built using Bootstrap
https://colorlib.com/wp/themes/shapely/
62 stars 61 forks source link

Dates are duplicated #334

Open nodarik opened 1 year ago

nodarik commented 1 year ago

Posts showing dates as duplicated in a single post: https://prnt.sc/uNoztQ0OriCX For more check this link: https://colorlibsupport.com/t/the-date-of-blog-post-shows-two-dates/32608

Athanas7a commented 3 months ago

I had the same issue but I found a temporary fix: Wordpress Dashboard > Appearance > Theme File Editor: //shapely/inc/template-tags.php And then you edit the first 82 lines as follows:

<?php
/**
 * Custom template tags for this theme.
 *
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package Shapely
 */

if ( ! function_exists( 'shapely_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function shapely_posted_on() {
        $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
        /** if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
            $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
        } */

        $time_string = sprintf(
            $time_string,
            esc_attr( get_the_date( 'c' ) ),
            esc_html( get_the_date() ),
        /** esc_attr( get_the_modified_date( 'c' ) ),
            esc_html( get_the_modified_date() )   */
        ); ?>

        <ul class="post-meta">
        <li><i class="fa fa-user"></i><span><a
                    href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
                    title="<?php echo esc_attr( get_the_author() ); ?>"><?php esc_html( the_author() ); ?></a></span>
        </li>
        <li><i class="fa fa-calendar"></i><span class="posted-on"><?php echo wp_kses_post( $time_string ); ?></span></li>
        <?php shapely_post_category(); ?>
        </ul>
        <?php
        echo ( is_archive() ) ? '<hr>' : '';
    }
endif;

if ( ! function_exists( 'shapely_posted_on_no_cat' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function shapely_posted_on_no_cat() {

        if ( is_singular( 'jetpack-portfolio' ) ) {
            $post_author = get_theme_mod( 'project_author', true );
            $post_date   = get_theme_mod( 'project_date', true );
        } else {
            $post_author = get_theme_mod( 'post_author', true );
            $post_date   = get_theme_mod( 'post_date', true );
        }

        $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
        /** if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
            $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
        } */

        $time_string = sprintf(
            $time_string,
            esc_attr( get_the_date( 'c' ) ),
            esc_html( get_the_date() ),
        /** esc_attr( get_the_modified_date( 'c' ) ),
            esc_html( get_the_modified_date() )       */
        );

        if ( $post_date || $post_author ) :
        ?>

        <ul class="post-meta">
        <?php if ( $post_date ) : ?>
            <li><span class="posted-on"><?php echo wp_kses_post( $time_string ); ?></span></li>
        <?php endif ?>
        <?php if ( $post_author ) : ?>
            <li><span><?php echo esc_html__( 'by', 'shapely' ); ?> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( get_the_author() ); ?>"><?php esc_html( the_author() ); ?></a></span></li>
        <?php endif ?>
        </ul>
        <?php
        endif;
    }
endif;

[continues...]

This comments out the parts that checks and parses the dates the post was modified.

wreidlinger commented 1 month ago

@Athanas7a thanks for your bugfix! It worked like a charm. Quite sad that the official "creator" of this theme is not able to fix this easy issue with an update.