Archived topic
Removing/Disabling hyperlinks in Generate Press archive post titles?
14 replies · Started by JANEK on June 16, 2018
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() )
);
}
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 :)
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.
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?
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.
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..
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?
You can send it to us in an email to support@generatepress.com - just be sure to mention this topic in the email :)
You can do something like this: https://gist.github.com/generatepress/6f63d08f610ac5c6cc17e559aca517e4
In your case you would name the file: archive-glossary.php
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.
How are the external links added? Using a custom field?
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.
If you know the ID of the custom field, we may be able to add a conditional check to the template.
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.
If you ask their support they should be able to tell you pretty easily :)