function custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { $output .= continue_reading_link(); } return $output; }
function am_custom_excerpt($length) { global $post; $content = strip_tags($post->post_content); preg_match('/^\\s*+(?:\\S++\\s*+){1,' . $length . '}/', $content, $matches); echo "<p>" . $matches[0] . "" . continue_reading_link() . "</p>"; }
static function wp_get_excerpt($pid = 0, $pargs = array()) { // print_r($pargs); global $post; $fout = ''; $excerpt = ''; if ($pid == 0) { $pid = $post->ID; } else { $pid = $pid; } $po = get_post($pid); // echo $pid; print_r($po); $margs = array('maxlen' => 400, 'striptags' => false, 'stripshortcodes' => false, 'forceexcerpt' => false, 'aftercutcontent_html' => '', 'readmore' => 'auto', 'readmore_markup' => '', 'content' => ''); $margs = array_merge($margs, $pargs); if ($margs['content'] != '') { $margs['readmore'] = 'off'; $margs['forceexcerpt'] = true; } // print_r($margs); if ($po->post_excerpt != '' && $margs['forceexcerpt'] == false) { $fout = do_shortcode($po->post_excerpt); //==== replace the read more with given markup or theme function or default if ($margs['readmore_markup'] != '') { $fout = str_replace('{readmore}', $margs['readmore_markup'], $fout); } else { if (function_exists('continue_reading_link')) { $fout = str_replace('{readmore}', continue_reading_link($pid), $fout); } else { if (function_exists('dzs_excerpt_read_more')) { $fout = str_replace('{readmore}', dzs_excerpt_read_more($pid), $fout); } else { //===maybe in the original function you can parse readmore //$fout = str_replace('{readmore}', '<div class="readmore-con"><a href="' . get_permalink($pid) . '">' . __('read more') . ' »</a></div>', $fout); } } } //==== replace the read more with given markup or theme function or default END return $fout; } $content = ''; if ($margs['content'] != '') { $content = $margs['content']; // echo 'nowcontent'.$content; } else { if ($margs['striptags'] == false) { if ($margs['stripshortcodes'] == false) { $content = do_shortcode($po->post_content); } else { $content = $po->post_content; } } else { // echo 'pastcontent'.$content; $content = strip_tags($po->post_content); // echo 'nowcontent'.$content; } } // echo 'nowcontent'.$content.'/nowcontent'; $maxlen = intval($margs['maxlen']); // echo 'maxlen'.$maxlen; if (strlen($content) > $maxlen) { //===if the content is longer then the max limit $excerpt .= substr($content, 0, $maxlen); // echo ' excerpt - '.$excerpt.$maxlen; if ($margs['striptags'] == true) { $excerpt = strip_tags($excerpt); //echo $excerpt; } if ($margs['stripshortcodes'] == false) { $excerpt = do_shortcode(stripslashes($excerpt)); } else { $excerpt = strip_shortcodes(stripslashes($excerpt)); $excerpt = str_replace('[/one_half]', '', $excerpt); $excerpt = str_replace("\n", " ", $excerpt); $excerpt = str_replace("\r", " ", $excerpt); $excerpt = str_replace("\t", " ", $excerpt); } $fout .= $excerpt . $margs['aftercutcontent_html']; if ($margs['readmore'] == 'auto') { $fout .= '{readmore}'; } } else { //===if the content is not longer then the max limit just add the content $fout .= $content; if ($margs['readmore'] == 'on') { $fout .= '{readmore}'; } } //==== replace the read more with given markup or theme function or default if ($margs['readmore_markup'] != '') { $fout = str_replace('{readmore}', $args['readmore_markup'], $fout); } else { if (function_exists('continue_reading_link')) { $fout = str_replace('{readmore}', continue_reading_link($pid), $fout); } else { if (function_exists('dzs_excerpt_read_more')) { $fout = str_replace('{readmore}', dzs_excerpt_read_more($pid), $fout); } else { //===maybe in the original function you can parse readmore //$fout = str_replace('{readmore}', '<div class="readmore-con"><a href="' . get_permalink($pid) . '">' . __('read more') . ' »</a></div>', $fout); } } } // echo 'ceva23'.$fout.'ceva23'; // echo 'ceva24'.$po->post_content.'ceva24'; //==== replace the read more with given markup or theme function or default END return $fout; }