I have the following blog template with the the_content outputted. I have placed <!--more-->
However it does not appear to be functioning,
http://www.milknhny.co.uk/DVine/?page_id=19
Is there anything that needs to be included within functions for this to function?
Code Of my Blog Template
<?php
/*
Template Name: Blog Template
*/
?>
<?php get_header();?>
<?php echo get_the_post_thumbnail($post->ID, 'single-post-thumbnail'); ?>
<div id="maincontentwrap" role="main">
<?php query_posts('showposts=5'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="datebackground"><span class="day"><?php echo get_the_date('j'); ?></span> <span class="month"><?php echo get_the_date('M'); ?></span></div>
<div class="postsh1"><?php echo get_the_title(); ?></div>
<div id="blogwrapper">
Written by <?php the_author_posts_link() ?> in <?php the_category(); ?>
<?php the_content('read more...'); ?>
<br>
<div class="pagedivider"></div>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div><!-- #content -->
<?php get_footer(); ?>
EDIT
I have found this within the Twenty Twelve theme and ive tried to adapt this to my own however the – errors the actual code…
function DTheme_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'DTheme_excerpt_length' );
if ( ! function_exists( 'DTheme_continue_reading_link' ) ) :
/**
* Returns a "Continue Reading" link for excerpts
*
* @since Twenty Ten 1.0
* @return string "Continue Reading" link
*/
function DTheme_continue_reading_link() {
return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta- nav">→</span>', 'DTheme' ) . '</a>';
}
endif;
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*
* @since Twenty Ten 1.0
* @return string An ellipsis
*/
function DTheme_auto_excerpt_more( $more ) {
return ' …' . DTheme_continue_reading_link();
}
add_filter( 'excerpt_more', 'DTheme_auto_excerpt_more' );
?>
Is it a case i would need to adapt the above for this to work?
EDIT
Hi all, this appears to be part working after amazing help below, however it is still not displaying within the content wrap and also images for example are resizing… please see my code now and also screenshot
<?php get_header(); ?>
<div id="maincontentwrap" role="main">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="datebackground"><span class="day"><?php echo get_the_date('j'); ?></span> <span class="month"><?php echo get_the_date('M'); ?></span></div>
<div class="postsh1"><?php echo get_the_title(); ?></div>
<div id="blogwrapper">
Written by <?php the_author_posts_link() ?> in <?php the_category(); ?>
<?php the_content(); ?>
<br>
<div class="pagedivider"></div>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div><!-- #content -->
<?php get_footer(); ?>
I see several things that may be contributing to your issue.
First, you’re using a custom page template to display the blog posts index, instead of using
home.php
as specified by the Template Hierarchy. That might be a problem, because the<!--more-->
tag doesn’t work on singular pages, and since you’re doing funky things with the default query (more on that below), The global$more
on which<!--more-->
relies might not be getting set as you expect it to be.Proper configuration of static page as blog posts index
So, the first step is to set up a proper configuration for a static page as blog posts index:
Dashboard -> Settings -> Reading
home.php
Template Name: Blog Template
tag from the phpDoc headerDon’t stomp on the main query
If that alone doesn’t resolve your problem, then the next issue to investigate is the way you’re stomping on the default query with
query_posts()
. Do not ever usequery_posts()
, for anything, ever.If you want to set your blog posts index to display a given number of posts, then filter the
$query
viapre_get_posts
, like so:Then, get rid of your call to
query_posts()
in the template file.Proper usage of
<!--more-->
If that doesn’t resolve your problem, then the next step is to check your usage of the
<!--more-->
tag itself.Ensure that the tag is exactly
<!--more-->
, with no spaces between<!--
andmore
or betweenmore
and-->
.Issues Outside the Template
If that still doesn’t resolve your problem, you may have code somewhere, either in
functions.php
or in a Plugin, that is altering the functionality of the<!--more-->
tag.To test for a Plugin-related issue, deactivate all Plugins, and switch to the default Theme (currently: Twenty Twelve) and verify whether the
<!--more-->
tag works properly. If it then works properly, re-enable your Plugins one-by-one. If the<!--more-->
tag still works properly with all Plugins active, then the problem is somewhere in your Theme.The next step is to rule out your template file. If you’ve followed the steps above, rename
home.php
ashome.php.old
, so that WordPress falls back toindex.php
to render the Blog Posts Index. Then, verify whether the<!--more-->
tag works properly.If it does, then the problem is your template. If it doesn’t, then the problem is somewhere in
functions.php
.