[Resolved] Removing/Disabling hyperlinks in Generate Press archive post titles?

Home Forums Support [Resolved] Removing/Disabling hyperlinks in Generate Press archive post titles?

Home Forums Support Removing/Disabling hyperlinks in Generate Press archive post titles?

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #601414
    JANEK

    Good evening, I’m wondering if there’s a way to disable hyperlinks in the Generate Press archive post titles. For example I have set archive to display the full content of posts, and I don’t wish for them to be clickable for a specific category archive.

    I’ve already found some PHP code to disable author links on the forum, but I couldnt figure out the filter for post titles, nor could I figure out a way to just target archives.

    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() )
        );
    }
    
    GeneratePress 2.1.2
    GP Premium 1.6.2
    #601611
    Leo
    Staff
    Customer Support

    Hi there,

    This might be the simplest method:
    https://generatepress.com/forums/topic/disable-post-title-link/#post-582607

    Let me know if this helps πŸ™‚

    #601836
    JANEK

    Hi Leo,

    Thats probably the easiest I agree. Is it considered bad coding though to remove pointer events instead of properly disabling the links?

    My knowledge is pretty basic so I honestly don’t know.

    #601851
    Tom
    Lead Developer
    Lead Developer

    In order to completely remove it, you would need to use custom template files.

    Is it only one archive you’re targeting? A specific category?

    #601868
    JANEK

    Hey Tom,

    Ideally yes, but I wouldnt mind doing it either way.

    The category archive is a list of glossary terms which I don’t want people to be able to click through to as it provides no value, rather I just want all the terms to be displayed as complete posts(no excerpts) on the glossary category archive. I’ve achieved everything I want perfectly except for removing the links.

    The pointer events trick works great except some of the glossary terms link to external sites, this attribute I set with a plugin for those specific glossary terms. My understanding is that if I used a function to remove the default post title links from category pages, the plugin I’m using will still provide the external links as it’s applying it’s on PHP to specific titles where it’s enabled.

    #602110
    Tom
    Lead Developer
    Lead Developer

    If you adjust the template to remove the links, that plugin likely won’t work anymore.

    Is it only one specific category? If so, what’s it called/can you link me to it? It will help me give you specific instructions on naming the file etc..

    #602289
    JANEK

    Hey Tom,

    The page is on a dev site I’m currently working on, I can provide the link but it’s password protected. Am I able to provide this in a secure way?

    #602323
    Tom
    Lead Developer
    Lead Developer

    You can send it to us in an email to support@generatepress.com – just be sure to mention this topic in the email πŸ™‚

    #602841
    Tom
    Lead Developer
    Lead Developer

    You can do something like this: https://gist.github.com/generatepress/6f63d08f610ac5c6cc17e559aca517e4

    In your case you would name the file: archive-glossary.php

    #603455
    JANEK

    Damn that’s a lot of code, you are a champion for doing this!

    Thanks so much, really appreciate the effort!

    Looks like it strips the external links on the titles as well, which is a bummer. But at least now I know this is how to disable the links with PHP.

    #603686
    Tom
    Lead Developer
    Lead Developer

    How are the external links added? Using a custom field?

    #604053
    JANEK

    The plugin called Page Links To, adds a custom field to every page and post that allows you to set an alternate url external or internal. I assume it’s just intercepting the standard WordPress links and changing them. But I dont know much about the more technical aspects of WordPress so I might be pretty far off the mark.

    #604532
    Tom
    Lead Developer
    Lead Developer

    If you know the ID of the custom field, we may be able to add a conditional check to the template.

    #604939
    JANEK

    I had a look at the PHP file in the plugin folder, it seems pretty well tagged but I wasn’t able to identify the custom field ID at the moment. I’ll have another look when I get some time later tonight or on the weekend.

    I dont want you to bend over backwards on this one. I might just use your original fix, and change the posts to have external links in the body text instead of the title.

    #605373
    Tom
    Lead Developer
    Lead Developer

    If you ask their support they should be able to tell you pretty easily πŸ™‚

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