Archived topic
Read more CSS is adding it to the bottom on post
11 replies · Started by Bob on July 10, 2021
In another thread here I found and it was recommended to use this CSS in order to give some padding and move the read more link to the right
.read-more-container {
margin-top: 10px;
text-align: right;
}
As a a result I am finding it now at the end of full posts. For example if you scroll down to the end of this post you will find it there in the bottom right corner. Any idea why? Thanks!
Hi there,
Not sure if I fully understand.
So basically you don't want that CSS to apply to single posts?
If so edit it to this:
.blog .read-more-container, .archive .read-more-container {
margin-top: 10px;
text-align: right;
}
Thanks Leo, yes that is exactly what I want. I don't understand why anyone would ever want that at the end of a full post :) Oddly enough when I changed this CSS is moves it to the left but it remains on full posts. Something to add that would take it off of the full post?
Hi Bob,
I don't think the read more container is added to a single post by default, are you using a custom template or custom function?
Can you try to disable all plugins except GP Premium? And if you are using a child theme, can you switch back to the parent theme?
Let me know :)
Okay, so I found the problem but not sure what to do.
Awhile back I was not able to get my "read more" on my archives page. I believe I had either found it here somewhere or was instructed through this forum, but I was told to add this snippet which I did.
add_action( 'generate_after_entry_content', 'tu_static_read_more_button' );
function tu_static_read_more_button() {
?>
<p class="read-more-container">
" ">Read more
</p>
<?php
}
Now when I disable that snippet, the "read more" disappears from the single post, but it now also doesn't show on my archives page, which brings back an old problem :( Any suggestions?
Previously when checking that I had disabled all plugins and that didn't resolve the older problem either.
I see what's the issue, can you try this PHP snippet instead of the one you are using currently:
add_action( 'generate_after_entry_content', 'tu_static_read_more_button' );
function tu_static_read_more_button() {
?>
<?php if ( is_home() || is_archive() ) : ?>
<p class="read-more-container">
<a href="<?php the_permalink(); ?>" class="button">Read more</a>
</p>
<?php endif; ?>
<?php
}
Let me know :)
Yay, that did it. Thanks! One last question... I think also part of the reason for that snippet was also to remove the button on the read more in the archives. Because now that is back LOL. I think that was another needed fix because even though I have it untoggled in the customizer for archive, they are still showing. Is that last fix possible (seems like ti never ends huh :)
Do you just want the read more on the blog page, not archive pages?
No, it just appeared on the blog page and that doesn't make sense to have it there.
I want it only on the archives and no button, only text. Does that make sense. I added the CSS to move it to the right and down a bit.
Hi Bob,
No, it just appeared on the blog page and that doesn’t make sense to have it there.
You can modify Ying's PHP snippet so it only appears on archive pages and not the blog pages. Simple remove is_home() || from the if condition.
I want it only on the archives and no button, only text. Does that make sense. I added the CSS to move it to the right and down a bit.
The PHP has class="button" that turns it into a button. We can remove that as well.
Try this.
add_action( 'generate_after_entry_content', 'tu_static_read_more_button' );
function tu_static_read_more_button() {
?>
<?php if ( is_archive() ) : ?>
<p class="read-more-container">
<a href="<?php the_permalink(); ?>">Read more</a>
</p>
<?php endif; ?>
<?php
}
Excellent, thank you so much. That did the trick. Cheers!!
No problem. Glad to be of any help. :D