WP Post Excerpt-01
functions.php
function excerpt($num) {
$limit = $num+1;
$excerpt = explode(' ', get_the_excerpt(), $limit);
array_pop($excerpt);
$excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>Read More</a>";
echo $excerpt;
}
Call Function: <?php echo excerpt('15'); ?>
function excerpt($num) {
$limit = $num+1;
$excerpt = explode(' ', get_the_excerpt(), $limit);
array_pop($excerpt);
$excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>Read More</a>";
echo $excerpt;
}
Call Function: <?php echo excerpt('15'); ?>
WP Post Excerpt-02
functions.php
function new_excerpt_length($length) {
return 100;
}
add_filter('excerpt_length', 'new_excerpt_length');
function new_excerpt_more( $more ) {
return ' Read More';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
Call function:
the_excerpt() ;
function new_excerpt_length($length) {
return 100;
}
add_filter('excerpt_length', 'new_excerpt_length');
function new_excerpt_more( $more ) {
return ' Read More';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
Call function:
the_excerpt() ;
WP Post Excerpt-03
functions.php
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
if (strlen($_GET['p']) > 0) {
echo $content;
}
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo $content;
echo "…</p>";
echo "<span class=\"readmore\"><a href=\"";
the_permalink();
echo "\">".$more_link_text."</a></span>";
}
else {
echo $content;
}
}
Call function:
<?php the_content_limit(400, "Read More") ?>
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
if (strlen($_GET['p']) > 0) {
echo $content;
}
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo $content;
echo "…</p>";
echo "<span class=\"readmore\"><a href=\"";
the_permalink();
echo "\">".$more_link_text."</a></span>";
}
else {
echo $content;
}
}
Call function:
<?php the_content_limit(400, "Read More") ?>
Excerpt Example
<?php get_header(); ?>
<div class="internal_page">
<div class="stracture">
<div class="content floatleft">
<div class="breadcumbs">
<?php if (function_exists('wordpress_breadcrumbs')) wordpress_breadcrumbs(); ?>
</div>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?php the_post_thumbnail('post-image', array('class' => 'imgthumb')); ?>
<div id="post-title" class="fix">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div> <!-- end div .post-title -->
<div class="entry">
<?php get_template_part( 'postmeta' ); // Post Meta (postmeta.php) ?>
</div>
<?php comments_template( '', true ); ?>
</div> <!-- end div .entry -->
</div> <!-- end div .post -->
<?php endwhile; ?>
<?php else : ?>
<div class="post">
<h3><?php _e('404 Error: Not Found', 'imran_business'); ?></h3>
</div>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
<div class="internal_page">
<div class="stracture">
<div class="content floatleft">
<div class="breadcumbs">
<?php if (function_exists('wordpress_breadcrumbs')) wordpress_breadcrumbs(); ?>
</div>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?php the_post_thumbnail('post-image', array('class' => 'imgthumb')); ?>
<div id="post-title" class="fix">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div> <!-- end div .post-title -->
<div class="entry">
<?php the_excerpt(); ?>
or
<div class="blogexcerpt"><?php echo excerpt('58'); ?></div>
<div class="space"><?php get_template_part( 'postmeta' ); // Post Meta (postmeta.php) ?>
</div>
<?php comments_template( '', true ); ?>
</div> <!-- end div .entry -->
</div> <!-- end div .post -->
<?php endwhile; ?>
<?php else : ?>
<div class="post">
<h3><?php _e('404 Error: Not Found', 'imran_business'); ?></h3>
</div>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>