Been working on a WordPress problem that’s been vexing me for the past few weeks. Since I use WP to run the entire websites, I typically place the blog section as a separate sub-page under the website root. My site structure might look like this:
- http://www.example.com = the website’s home page
- http://www.example.com/blog = where the blog will appear
- http://www.example.com/wordpress = where WordPress lives
The problem that I and others were facing was that blog posts on the sub-page were showing the full post instead of the portion before the
The function get_the_content (called within the_content function) will only show the post teaser if it’s not a single or non-permalink page. The solution involves making WordPress think that the sub-page is a non-permalink page. I accomplished this by setting the global $more variable to 0 in my page template. For example:
Now, when I execute the WordPress Loop in this sub-page, the posts that are displayed correctly show the teaser and not the entire post. Developers may want to store the current value of the $more variable in case other functions/plugins rely it.