-
Anonymous
How can I remove the link from the title and image in the standard category loop?
-
Hi there,
The easiest way is to use this CSS:
body.archive.category .inside-article a { pointer-events:none; }
-
Anonymous
Hello Ying,
I don’t think the solution is particularly good because the source text still contains the link. This is very impractical for SEO.
Can’t you overwrite this with a hook?
-
When you say link, do you mean links of the title and image only? or do you mean the links in the post meta like author name/cateogry/tag/comments as well?
-
Anonymous
I mean only the link in the link in the entry-title an in the link post-image.
<div class="inside-article"> <header class="entry-header"> <h3 class="entry-title" itemprop="headline"><a href="xx/de/standorte/deutschland/museen-berlin/museum-fuer-naturkunde/" rel="bookmark">Museum für Naturkunde</a></h3> </header> <div class="post-image"> <a href="xx/de/standorte/deutschland/museen-berlin/museum-fuer-naturkunde/"> <img width="900" height="600" src="https://xxx/wp-content/uploads/museum-fuer-naturkunde-berlin-aussenansicht.jpg" class="attachment-full size-full wp-post-image" alt="Museum für Naturkunde - Berlin - Außenansicht" itemprop="image" decoding="async" srcset="https://xxx/wp-content/uploads/museum-fuer-naturkunde-berlin-aussenansicht.jpg 900w, https://xxx/wp-content/uploads/museum-fuer-naturkunde-berlin-aussenansicht-300x200.jpg 300w, xxx/wp-content/uploads/museum-fuer-naturkunde-berlin-aussenansicht-768x512.jpg 768w" sizes="(max-width: 900px) 100vw, 900px"> </a> </div> <div class="entry-summary" itemprop="text"> content.. </div>
-
1. to remove the link from featured image:
add_filter( 'generate_featured_image_output', function( $output ) { if ( ! is_category() ) { return $output; } return sprintf( '<div class="post-image"> %1$s </div>', get_the_post_thumbnail( get_the_ID(), apply_filters( 'generate_page_header_default_size', 'full' ) ), apply_filters( 'generate_inside_featured_image_output', '' ) ); } );
2. to remove the link from entry-title:
add_filter( 'generate_get_the_title_parameters', function( $params ) { // Check if we are in a non-singular context and not dealing with a "link" post format if ( ! is_singular() && 'link' !== get_post_format() ) { // Remove the link from the entry title $params['before'] = sprintf( '<h2 class="entry-title"%s>', 'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : '' ); $params['after'] = '</h2>'; // Close the h2 without a link } return $params; } );
-
Anonymous
Hi Ying,
That seems to be the wrong hook. Neither works. That should be for the list in the category page.
-
Alvind
Hi there,
Could you let me know how you added those snippets to your site? Both snippets should work for the standard archives.
- You must be logged in to reply to this topic.