Remove link from singular post titles
-
Afternoon .. I need a little help with some php.
I’m trying to remove the link from titles on singular post pages, I understand how to do it; but the php formatting breaks.
Currently I have:
<?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } else { echo '<h2 class="entry-title">'; } ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a><?php if ( is_singular() ) { echo '</h1>'; } else { echo '</h2>'; } ?>
I tried moving the anchor to within the non-singular, but I realise you can’t echo within an echo, so this attempt is broken:
<?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } else { echo '<a href="<?php the_permalink(); ?><h2 class="entry-title">'; } ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?><?php if ( is_singular() ) { echo '</h1>'; } else { echo '</a></h2>'; } ?>
Could somebody help me solve this please?
Thanks…
- The topic ‘Remove link from singular post titles’ is closed to new replies.