<?php
/*
Template Name: second
*/
?>
<?php get_header(); ?>
<?php query_posts(array('post_type'=>'event')); ?>
<?php if(have_posts()) while(have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="entry">
<div class="thumbnail"><?php the_post_thumbnail('full'); ?></div>
<h1 class="title"><?php the_title(); ?></h1>
<div class="content page">
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<div class="page-link">'.__('Pages', 'cpotheme').':', 'after' => '</div>')); ?>
</div>
</div>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The page acts like an index.php What should I amend in order to make the title as the link to the full page and make display only an excerpt of the content?
You only need two small changes (1st and 3rd lines), though I also took the liberty of tweaking the classes on the div to what seemed more appropriate:
You’ll need to form a html anchor tag using WordPress functions, here’s the example.
Example –
And to display only excerpt there’s functions called
the_excerpt()
First off: Interesting Question!
Second: you need to add the
<!--nextpage-->
tag in your post one or multiple times. Else it won’t work.The plugin:
What this plugin does is intercepting the output of
get_permalink()
, which is called internally bywp_link_pages()
. Insideget_permalink()
, we got theget_post_permalink()
function that returns for custom post types. There we find the'post_type_link'
-filter and this is where we hook in.Then we take the
global $pages
, which holds an array of the post content splitted by the<!--nextpage-->
HTML comment. Our static variable is a counter that helps us determining which part we should return – based on the times the function was called (starting at0
).The last thing is that we append this part from
$pages
to our post link. As theesc_url()
function intercepts our permalink and would mess up all our Uppercase letters, spaces, etc., we attach a single firing filter there too and just return the original string.The solution is not completely perfect. I hadn’t got around getting rid of the first number and there seems to be a slight problem with retrieving the last link in some cases. It also had the problem, that core doesn’t offer a possibility to get rid of the appended
</a>
closing tag, so I had to add fake links there. Those don’t get displayed, won’t be followed by search engines and don’t harm. They’re just not beautiful, but that’s the only possibility.