Black Friday sale! Get 25% off WPSP Pro! Discount automatically applied at checkout.

[Resolved] Remove Links from date/author

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Remove Links from date/author

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #3238
    Sven
    Participant

    Hi Tom,
    first of all, a big thank you for your awesome work. Really enjoy the combination of GP + WPShowposts (both Premium).

    I’m looking for a solution how to remove the links from the date/autor meta box within a WP-Post-List embeded via the sections-feature. Currently using the following filter, which works with the standard blog-overview/single posts. Seems I’m missing something here:

    add_filter( 'generate_post_date_output','tu_remove_date_link', 10, 2 );
    function tu_remove_date_link( $output, $time_string ) {
    	printf( '<span class="posted-on">%s</span>',
    		$time_string
    	);
    }
    add_filter( 'generate_post_author_output','tu_no_author_link' );
    function tu_no_author_link() {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>',
    			__( 'by','generatepress'),
    			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
    			esc_html( get_the_author() )
    		)
    	);
    }

    Thanks in advance. Cheers from Bonn, Germany
    Sven

    #3452
    Tom
    Keymaster

    Hi there,

    Sorry for not getting back to you sooner!

    WPSP uses different filters. This should help:

    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
        );
    }
    #6169
    Thierry
    Participant

    Hello,

    How i can remove the link on the title and the featured image ?

    Thx

    #6172
    Tom
    Keymaster
    #6186
    Thierry
    Participant

    Thanks Tom 🙂

    #6188
    Tom
    Keymaster

    You’re welcome 🙂

    #10634
    Damond
    Participant

    Tom this this work for removing the category link as well?

    #10638
    Tom
    Keymaster

    No, but you can try this to do that:

    add_filter( 'wpsp_terms_output', function( $output ) {
        return sprintf( '<span class="wp-show-posts-terms wp-show-posts-meta">%1$s</span>',
            strip_tags( get_the_term_list( get_the_ID(), $settings[ 'taxonomy' ], '', apply_filters( 'wpsp_term_separator', ', ' ) ) )
        );
    } );

    Let me know 🙂

    #15438
    hezuf123
    Participant

    To have it all in one place, how would I remove the link from the comment count?

    #15502
    Tom
    Keymaster

    Hi there,

    It’s not possible, unfortunately, as the WP function itself hardcodes the link into the function.

    You would have to add your own function in there to display the number only.

    #18894
    Chris
    Participant

    Hi Tom!

    The filters are working for me, but it’s resulting in the vertical bar appearing after the date:

    Author Name September 1, 2020 |

    With links it appears as expected:

    Author Name | September 1, 2020

    Sorry I have no example link: this is still a local testing site. Thanks!

    GP Pro & latest beta of WPSP

    #18918
    Tom
    Keymaster

    Hi there,

    Can you share the exact code you’re using?

    #18935
    Chris
    Participant

    As below:

    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
        );
    }
    #18984
    Tom
    Keymaster

    That looks good. Could be CSS – can you link me to the page?

    #19006
    Chris
    Participant

    Hi Tom,

    The site is still in local development, but I made a version of the relevant page:

    Test site blog index

    Hope that works!

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.