Friday, April 17th, 2009, 1499 days ago
WordPress trick of ‘more’ tag in page templates
I have a similar problem. On page.php, after the loop I’m using get_posts to grab and display some Posts that are related to the current Page.
Everything is fine except that I’m getting full content without the more link. Does the more quicktag not work with get_posts on page.php?
Here is the solution:
the “more…” does NOT work on Pages by default – a Page displays just one single entry, so no need for it: there is no “multi-Page” view in WP.
According to some older posts in this forum that you could find by searching – this should address the issue:
<?php $more = 0; ?>if placed before the query.
After much experimentation, here is what I’ve learned:
The more quicktag does not seem to work with
get_posts()outside the loop even when using $more = 0; or a custom template instead of page.php.The more quicktag will work with
query_posts()outside the loop if you set $more = 0; even if you use page.php.A note for people switching functions. Use category= with get_posts(). Use cat= with query_posts().
Next challenge: get tags working on my related posts displayed below a page’s content.
Here’s my query for posterity:
<?php if (isset ($relatedcat)) {
// related cat set in custom field
$query= 'numberposts=99&cat='.
$relatedcat.'&orderby=date&order=ASC';
query_posts($query); // run the query
global $more; $more = 0; // allow more quicktag
while (have_posts()) : the_post(); // the loop
setup_postdata($post);
?>
<div class="post" >
[From wordpress.org, all rights reserved by original ahtors]
POSTS MAY BE OF INTEREST

A successful way to disable all WordPr...