For a project of mine using the UnderStrap Theme for WordPress, I wanted to customise my category archive pages by showing listed posts without the hyper link.
Customising the WordPress loop in Understrap to remove link from post title
Here’s how I achieved this:
- In the WordPress dashboard, browse the menu on the left and go to Appearance » Theme File Editor.
- Click » Theme File Editor, this will load up the Edit Themes page.
- On the right side of the page, you’ll see a list of links with the header Theme Files.
- The list is scroll-able. Scroll down until you hit the item Loop Templates. The right-sided arrow next to the label indicates that Loop Templates has sublinks which will be revealed if you click it.
- Click » Loop Templates.
- By clicking on Loop Templates you should now see a list of blue hyperlinks beneath (these are sub sections of the category Loop Templates).
- Scroll down the list (approximately seven items deep) and you should find a link named Content.php.
- Click » Content.php this will load the script inside the file within the Edit Themes window.
- Scroll down the script within the page until you find written:
sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ),
- I replaced the code above with:
the_title( '<h2>', '</h2>' );
- …this worked for removing the link from the title.
- Next, I removed the following from the script:
<footer class="entry-footer"> <?php understrap_entry_footer(); ?> </footer>
- …this removed the category link in the footer of each archive entry
- Last of all, to customise the link and button text globally for all archive post entries, go back into the Theme Files list on the right hand side of the editor and scroll down to find inc (about 4 items down the list).
- Click » inc » set-up.php and find the following script:
<a class="btn btn-secondary understrap-read-more-link" href="' . esc_url( get_permalink( get_the_ID() ) ) . '">' . __( 'Read More...',
- To have the ‘Read More…’ button link to your homepage for example, modify the script above to include:
- To change the ‘Read More…’ button, simply overwrite is there, take this for example:
__( 'My New Button Text...',