Home › Forum › Customization › When viewing a single post page, make the title not a link but just text
This topic contains 10 replies, has 2 voices, and was last updated by StartupWP 4 years, 6 months ago.
- AuthorPosts
- September 8, 2014 at 11:30 AM #1846
Hi,
First of all, your theme is great, I love it.
I have only one problem: When you click on the title of a post to read it it will open the post page with the full content of that page. Right now the title of the post page is a link to the same post, linking the page to itself. I will like to make the title to be only text on the post page.Thank you
September 8, 2014 at 1:34 PM #1850If it’s simply a matter of appearance, you can use:
.single .entry-title a { color: #777; cursor: text; font-size: 25px; text-decoration: none; }
https://startupwp.com/topic/customizing-your-theme/
Otherwise, we’ll need to dig into the code to hack the PHP.
September 8, 2014 at 1:56 PM #1851Thank you for your quick reply but it’s not about appearance. I don’t think that you understood me. Right now the title of each post is also a link to the same post, basically the page will have a loop link. I think that when you load the full post the title should be only text, not a link.
To understand better please take a look here. As you can see the title of the post, “The tech news of the day. 09/08/2014” is also a link to the same page. I will like to be only text.
This is the code:
<a href="http://www.computeronechicago.com/news-of-the-day-september-08-2014/" title="The tech news of the day. 09/08/2014" rel="bookmark">The tech news of the day. 09/08/2014</a>
I will like to remove the anchor html tag.Thank you
September 8, 2014 at 4:54 PM #1852I fixed it. For everybody who will want to do it:
On the child theme modify the entry.php file:
Replace
<?php if ( is_singular() ) {echo '<h1 class="entry-title">';} else {echo '<h2 class="entry-title">';} ?><a href="<?php the_permalink(); ?>" title="<?php printf( __('Read %s', 'startup'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a><?php if ( is_singular() ) {echo '</h1>';} else {echo '</h2>';} ?>
with
<?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } else { echo '<h2 class="entry-title">'; } ?><?php the_title(); ?><?php if ( is_singular() ) { echo '</h1>'; } else { echo '</h2>'; } ?> <?php edit_post_link(); ?>
September 9, 2014 at 1:51 PM #1855Actually, that will disable the ability to reach the single post from archive, tag, cat and search pages, instead, use:
<?php if ( is_singular() ) {echo '<h1 class="entry-title">';} else {echo '<h2 class="entry-title">';} ?><?php if ( !is_singular() ) {echo '<a href="' . get_permalink() . '" title="<?php printf( __('Read %s', 'startup'), the_title_attribute('echo=0') ); ?>" rel="bookmark">';}<?php the_title(); ?><?php if ( !is_singular() ) {echo '</a>';}<?php if ( is_singular() ) {echo '</h1>';} else {echo '</h2>';} ?>
Thank you.
September 9, 2014 at 3:07 PM #1858Hi,
I tried your code but I’m getting the following error: “Parse error: syntax error, unexpected ‘Read’ (T_STRING), expecting ‘,’ or ‘;’ in …/wp-content/themes/startuppro-child/entry.php on line 3”
For now I put back my code.
Thank you.
September 9, 2014 at 9:08 PM #1861Apologies, give this a try:
<?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } else { echo '<h2 class="entry-title">'; } ?><?php if ( !is_singular() ) { echo '<a href="' . get_permalink() . '">'; } ?><?php the_title(); ?><?php if ( !is_singular() ) { echo '</a>'; } ?><?php if ( is_singular() ) { echo '</h1>'; } else { echo '</h2>'; } ?>
September 10, 2014 at 11:22 AM #1865Hi,
I tried the second code but it’s not working either, I’m getting the same error message:
“Parse error: syntax error, unexpected ‘}’, expecting ‘,’ or ‘;’ in …/wp-content/themes/startuppro-child/entry.php on line 3”That’s OK. For what I need I think that the solution that I found is good enough. If I will notice something not working properly I can always just delete the file from the child theme and it will use the original one from the parent theme.
Thank you for your help.
September 10, 2014 at 2:29 PM #1866Fixed another error in the above code if you’d like to give it a try.
Thank you.
September 10, 2014 at 2:36 PM #1867Yes, this time everything works just fine.
Thank you very much for your help. You have a great theme.
September 10, 2014 at 2:46 PM #1868Excellent.
- AuthorPosts
You must be logged in to reply to this topic.