Thread Starter
ghaib
(@ghaib)
I don’t have a link at the moment, just doing some testing and research.
Basically, is there a php string in WP to call the “read more button”, which is separated from the get_content string?
E.g. this:
<?php the_content('Read more »'); ?>
Becomes:
<?php the_content(); ?> and this <?php ('Read more »'); ?>
yes, it’s possible to do that. but i need to see your theme and your codes. until then i cannot tell you anything about the way you can do it.
nah, this is probably what you want.
Peter
Thread Starter
ghaib
(@ghaib)
@kiano.ro: I posted the code, I’m basically looking to separate the two, there isn’t more to it, it’s not theme specific.
Is there a code which resembles <?php ('Read more »'); ?>
(without the “get_content” part)?
In your new div, but within the same loop, put:
<a href="<?php the_permalink(); ?>Read More</a>
Thread Starter
ghaib
(@ghaib)
@jrav001: Thanks for the tip, it works, however, it always displays the “Read more” button, even if read more isn’t used in the post.
You can add code to the string….
<?php the_content('<div>Read more »</div>'); ?>
If you’re trying to end the content DIV and start a new one, then you could use..
<?php the_content('</div><div>Read more »'); ?>
The first closing DIV will close the current DIV (the one the content is in i assume), then open a new, which would be closed by the contents regular closing tag..
So rather then having..
<div>
some content
<div> more </div>
</div>
you’d end up with..
<div>
some content
</div><div> more
</div>
..is that what you mean?
Thread Starter
ghaib
(@ghaib)
@t31os_
Yep, that’s exactly what I mean. I solved it partially by doing this:
<?php the_content(''); ?>
And then this, in a separate div:
<a href="<?php the_permalink(); ?>">Read more</a>
However, a new problem emerges: the “Read more” button will always be present, linking to the post, whether <!--more-->
is specified in the post or not.
Example:
<?php if( strpos( $post->post_content , "<!--more-->" ) != false ) { ?>
<div>
<a href="<?php the_permalink(); ?>">Read more</a>
</div>
<?php } ?>
To add to the above, the reasoning for using $post->post_content
over get_the_content
is simple.
With get_the_content, the data has already had the shortcodes processed, therefore <!--more-->
will not exist, the same does not ring true for $post->post_content
.
ghaib please mark your thread as resolved if the information supplied was sufficient.
jrav001 nearly had it but use span with display:block; not div otherwise code will not validate ;)…
PHP:
<?php the_content('<span class="more">Read More » </span>'); ?>
CSS:
.more {
display:block;
margin-top:10px;
text-align:right;
}