Home › Forums › Pro Support › Remove Links from date/author
Tagged: meta, Remove author/date link
- This topic has 19 replies, 6 voices, and was last updated 3 years ago by
Tom.
-
AuthorPosts
-
January 9, 2018 at 2:14 pm #3238
Sven
ParticipantHi 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
SvenJanuary 28, 2018 at 8:14 pm #3452Tom
KeymasterHi 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 ); }
October 12, 2018 at 8:10 am #6169Thierry
ParticipantHello,
How i can remove the link on the title and the featured image ?
Thx
October 12, 2018 at 5:31 pm #6172Tom
KeymasterOctober 14, 2018 at 12:58 pm #6186Thierry
ParticipantThanks Tom 🙂
October 14, 2018 at 7:28 pm #6188Tom
KeymasterYou’re welcome 🙂
August 7, 2019 at 3:18 pm #10634Damond
ParticipantTom this this work for removing the category link as well?
August 7, 2019 at 5:07 pm #10638Tom
KeymasterNo, 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 🙂
May 9, 2020 at 3:57 pm #15438hezuf123
ParticipantTo have it all in one place, how would I remove the link from the comment count?
May 12, 2020 at 4:51 pm #15502Tom
KeymasterHi 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.
September 3, 2020 at 3:39 am #18894Chris
ParticipantHi 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
September 3, 2020 at 2:18 pm #18918Tom
KeymasterHi there,
Can you share the exact code you’re using?
September 3, 2020 at 5:02 pm #18935Chris
ParticipantAs 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 ); }
September 4, 2020 at 2:27 pm #18984Tom
KeymasterThat looks good. Could be CSS – can you link me to the page?
September 4, 2020 at 6:47 pm #19006Chris
ParticipantHi Tom,
The site is still in local development, but I made a version of the relevant page:
Hope that works!
-
AuthorPosts
- You must be logged in to reply to this topic.