0

How can I remove the link from the page title in my WordPress theme?

Here's the link to my test site and below is the code responsible for that:

<h1 class='post-title <?php echo $titleClass; ?>'>
    <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php 
        _e('Permanent Link:','avia_framework')?> <?php 
        the_title(); ?>"><?php the_title(); ?></a>
</h1>

When I removed <a href=""> </a>, it removed the complete title and nothing is visible.

Edit: I want the title to remain on the page, but not linked to the post.

1

Perhaps when you removed your a tag you also remove the nested the_title(); function?

the_title(); is the Wordpress function which spits out the plain text post/page title so having that in your h1 like below should get you the results you're expecting. Of course there may also be some CSS which is affected due to the removal of your <a> tag

<h1 class='post-title <?php echo $titleClass; ?>'>
    <?php the_title(); ?>
</h1>
0

remove a <a> teg only use <?php the_title(); ?> in h1 teg another below code add in function.php

add_action('wp_head' , 'remove_post_list_title_links');
function remove_post_list_title_links() {
    ?>
    <script id="remove-links-in-title" type="text/javascript">
        jQuery(document).ready(function($) {
            $('.entry-title').each(function() {
                var $title_link = $('a[rel="bookmark"]' , $(this)),
                    $title_text = $title_link.text();
                $title_link.remove();
                $(this).prepend($title_text);
            });
        });
    </script>
    <?php
}

protected by Community Jan 24 '18 at 5:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.