Hallo,
Ich habe das Plugin "evermore" getestet.
es ist soweit ein super plugin, jedoch kürzt es erst bei einem absatz
<p></p>
im theme magazine-basic ist sowas schon automatisch mit drinn, dass die vorschau auf 55 wörter gekürzt werden.
ich benutze das mystique theme und würde soetwas auch gerne einbauen.
mit dem more tag möchte ich nicht arbeiten, weil ich immer nach zb. 100 wörtern gekürzt haben möchte.
kann man das realisieren mit einem codeschnippsel oder so?
habe in meiner core.php folgendes gefunden:
// filter post content (for other pages than single)
function mystique_trim_the_content($the_contents, $read_more_tag, $perma_link_to = '', $all_words = 100, $allowed_tags = array('a', 'abbr', 'blockquote', 'b', 'cite', 'pre', 'code', 'em', 'label', 'i', 'p', 'span', 'strong', 'ul', 'ol', 'li')) {
if($the_contents != ''):
// process allowed tags
$allowed_tags = '<' .implode('><',$allowed_tags).'>';
$the_contents = str_replace(']]>', ']]>', $the_contents);
// exclude HTML and shortcodes from counting words
$the_contents = strip_tags($the_contents, $allowed_tags);
$the_contents = strip_shortcodes($the_contents);
if(!is_numeric($all_words)) $all_words = 9999; // assuming full post
// count all
if($all_words > count(preg_split('/[\s]+/', strip_tags($the_contents), -1))) return $the_contents;
$all_chunks = preg_split('/([\s]+)/', $the_contents, -1, PREG_SPLIT_DELIM_CAPTURE);
$the_contents = '';
$count_words = 0;
$enclosed_by_tag = false;
foreach($all_chunks as $chunk):
// is tag opened?
if(0 < preg_match('/<[^>]*$/s', $chunk)) $enclosed_by_tag = true; elseif(0 < preg_match('/>[^<]*$/s', $chunk)) $enclosed_by_tag = false;
// get entire word
if(!$enclosed_by_tag && '' != trim($chunk) && substr($chunk, -1, 1) != '>') $count_words ++;
$the_contents .= $chunk;
if($count_words >= $all_words && !$enclosed_by_tag) break;
endforeach;
// note the class named 'more-link'. style it on your own
$the_contents = $the_contents.' <a class="more-link" href="'.$perma_link_to.'">'.$read_more_tag.'</a>';
// native WordPress check for unclosed tags
$the_contents = force_balance_tags($the_contents);
endif;
return $the_contents;
}
Alles anzeigen
<?php if($post_settings['post_content']): ?>
<div class="post-content clear-block">
<?php
if($post_settings['post_content_length'] == 'f'): the_content(__('<img src="http://www.garnelen-hl.de/movie/wp-content/themes/mystique/images/weiterlesen.png" />','mystique'));
elseif($post_settings['post_content_length'] == 'e'): the_excerpt();
else:
$word_count = $post_settings['post_content_length'];
// save original post content to variable
$content = get_the_content();
// prevent tags strip | it's a bug in WordPress!
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
// throw out trimmed: content to process, read more tag, post permalink, words length
echo mystique_trim_the_content($content, __('<img src="http://www.garnelen-hl.de/movie/wp-content/themes/mystique/images/weiterlesen.png" />','mystique'), get_permalink($post->ID), $word_count);
endif; ?>
</div>
<?php endif; ?>
Alles anzeigen
warscheinlich ist es nur eine kleinigkeit, kann mir wer helfen ?
achso ganz wichtig, ich habe in meinen posts immer ein bild eingefügt, was natürlich bei der vorschau mit angezeigt werden soll.
soweit wie ich gelesen habe, macht the_excerpt das ja nicht ....
bitte um rat...