1. Home
  2. Knowledge Base
  3. Understrap Theme Tutorial
  4. How To Show Posts In WordPress Loop But Don’t Link To Them?

How To Show Posts In WordPress Loop But Don’t Link To Them?

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:

  1. In the WordPress dashboard, browse the menu on the left and go to Appearance » Theme File Editor. 
  2. Click » Theme File Editor, this will load up the Edit Themes page.
  3. On the right side of the page, you’ll see a list of links with the header Theme Files.
  4. 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.
  5. Click » Loop Templates.
  6. By clicking on Loop Templates you should now see a list of blue hyperlinks beneath (these are sub sections of the category Loop Templates).
  7. Scroll down the list (approximately seven items deep) and you should find a link named Content.php.
  8. Click » Content.php this will load the script inside the file within the Edit Themes window.
  9. Scroll down the script within the page until you find written:
    • <?php
      the_title(
      sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ),
      '</a></h2>'
      );
      ?>
  10. I replaced the code above with:
    • <?php
      the_title( '<h2>', '</h2>' );
      ?>
    • …this worked for removing the link from the title.
  11. 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
  12. 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).
  13. 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...',
  14. To have the ‘Read More…’ button link to your homepage for example, modify the script above to include:
    • esc_url( '/')
  15. To change the ‘Read More…’ button, simply overwrite is there, take this for example:
    • __( 'My New Button Text...',

References:

https://github.com/understrap/understrap/issues/348

the_title()

esc_url()

Was this article helpful?