Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Remove links from Category-Loop (Header,Image)

  • 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;
    }
  • 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?

  • 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;
    } );
  • Hi Ying,

    That seems to be the wrong hook. Neither works. That should be for the list in the category page.

  • Hi there,

    Could you let me know how you added those snippets to your site? Both snippets should work for the standard archives.

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