• Jessica

    (@jessica-korteman)


    Hi there,

    I added a PHP snippet to remove the link from the Author and Date (which I’ll post below this message). That worked fine, but now the separator ( | ) is appearing after the date instead of between the author and date. How can I fix this?

    Many thanks,

    Jessica

    add_filter( 'wpsp_author_output', 'tu_wpsp_remove_author_link' );
    function tu_wpsp_remove_author_link() {
        printf(
            '<span class="wp-show-posts-byline wp-show-posts-meta">
                <span class="wp-show-posts-author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">
                     <span class="author-name" itemprop="name">%1$s</span>
                </span>
            </span>',
            esc_html( get_the_author() )
        );
    }
    
    add_filter( 'wpsp_date_output', 'tu_wpsp_remove_date_link' );
    function tu_wpsp_remove_date_link() {
        $time_string = '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
    
        if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
            $time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%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() )
        );
    
        printf(
            '<span class="wp-show-posts-posted-on wp-show-posts-meta">%1$s</span>',
            $time_string
        );
    }

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Elvin

    (@ejcabquina)

    Hi Jessica,

    Let’s fix the code a bit:

    Try this:

    add_filter( 'wpsp_date_output', 'tu_wpsp_remove_date_link');
    function tu_wpsp_remove_date_link() {
        $time_string = '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
    
        if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
            $time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%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() )
        );
    
        return sprintf(
            '<span class="wp-show-posts-posted-on wp-show-posts-meta">%1$s</span>',
            $time_string
        );
    }
    
    add_filter( 'wpsp_author_output', 'tu_wpsp_remove_author_link');
    function tu_wpsp_remove_author_link() {
       return sprintf(
            '<span class="wp-show-posts-byline wp-show-posts-meta">
                <span class="wp-show-posts-author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">
                     <span class="author-name" itemprop="name">%1$s</span>
                </span>
            </span>',
            esc_html( get_the_author() )
        );
    }
    • This reply was modified 4 years, 11 months ago by Elvin.
    Thread Starter Jessica

    (@jessica-korteman)

    Thank you! That worked to move the separator into the right place. But now the links have reappeared over the author and date?

    Thread Starter Jessica

    (@jessica-korteman)

    Apologies! Never mind – it seems the PHP snippet automatically toggled off when I edited it. I had to go back in and switch it back on.

    It’s working as intended now – thank you so much! I really appreciate it!

    Plugin Support Elvin

    (@ejcabquina)

    Nice one. glad you got it sorted. No problem. 😀

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Term Separator Displaying After Date’ is closed to new replies.