0

I am using a custom database query to fetch posts.

In the post I have a break tag, which is displayed as <!--more--> in the database wp_posts table, but I can't get it to output like I would if I used wp query. It is basically ignored.

i tried using apply_filters like so, but to no avail:

<?php echo apply_filters("the_content", $post->post_content); ?>

I don't get either the "read more" anchor or the "read more" span tag in the post's content.

How can I get it with my custom query?

0

The <!-- more --> tag isn't applied via the the_content filter, it's included in the get_the_content() function, which checks for the existence of the tag within the content using a regex and then outputs the more link appropriately. this output is filtered via the the_content_more_link filter, but since you're not using get_the_content() you won't be able to leverage that. you'll need to perform a similar regex replacement in our custom code. I would recommend filtering your more link via the_content_more_link as well, for compatibility. You can see the code get_the_content() uses here: https://core.trac.wordpress.org/browser/tags/4.0.1/src/wp-includes/post-template.php#L255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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