Hallo zusammen!
Ich habe für ein Schulprojekt ein Wordpress Theme auf Basis von der Theme "WP-Basis" erstellt.
Auf meiner Worpdress-Seite (Noch nicht online) werden die Beiträge z.B. bei der Suche immer vollständig angezeigt. Bei vielen Blogs die ich kenne, wird bei den Beiträgen das Titelbild und die ersten Zeilen des Beitrags angezeigt. Darunter gibt es einen Button "read-more" mit dem man zur vollständigen Version des Beitrags kommt.
Ich habe herausgefunden, dass sich diese Funktion "Excerpt" nennt. ()http://codex.wordpress.org/Function_Reference/the_excerpt
Ich möchte das auf meiner Seite integrieren, ich habe aber keine Programmier- bzw. PHP-Kenntnisse.
Kann mich dabei vielleicht jemand unterstützen?
Meine search.php sieht folgendermaßen aus:
<?php
// Whether current WordPress query has results to loop over
if ( have_posts() ) {
do_action( 'MEINTHEME_search_query_result' );
$defaults = array(
'tag' => 'header',
'class' => 'page-header',
'before_txt' => '<h1 class="page_title">',
'txt' => sprintf(
__( 'Suchergebnis für: %s', 'MEINTHEME' ),
'<span class="suchbegriff">' . get_search_query() . '</span>'
),
'after_txt' => '</h1>'
);
$args = wp_parse_args( $args = array(), apply_filters( 'MEINTHEME_search_title', $defaults ) );
// check for class param
if ( ! empty( $args['class'] ) )
$class = ' class="' . $args['class'] . '"';
// check for param tag, if empty, don't generate markup
if ( ! empty( $args['tag'] ) ) {
$title = '<' . $args['tag'] . $class . '>' . $args['before_txt'] . $args['txt'] . $args['after_txt'] . '</' . $args['tag'] . '>';
} else {
$title = $args['before_txt'] . $args['txt'] . $args['after_txt'];
}
echo $title;
/* Start the Loop */
while ( have_posts() ) :
the_post();
/**
* If you want to overload this in a child theme then include a file
* called content-search.php and that will be used instead.
*/
get_template_part( 'parts/content', 'search' );
endwhile;
// if the loop has no results
} else {
/**
* Include the template for the loop dosn't find and result
* If you will overwrite this in in a child theme the include a file
* called no-results-search.php and that will be used instead.
*/
get_template_part( 'parts/no-results', 'search' );
} // endif
?>
</div> <?php // end #content ?>
</section> <?php // end section #primary
do_action( 'MEINTHEME_search_after_content' );
?>
Alles anzeigen
Meine index.php sieht so aus:
<?php
do_action( 'MEINTHEME_index_before_content' );
// Whether current WordPress query has results to loop over
if ( have_posts() ) {
/* Start the Loop */
while ( have_posts() ) :
the_post();
/**
* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'parts/content', get_post_format() );
endwhile;
// if the loop has no results
} else {
/**
* Include the template for the loop dosn't find and result
* If you will overwrite this in in a child theme the include a file
* called no-results-index.php and that will be used instead.
*/
get_template_part( 'parts/no-results', 'index' );
} // endif
do_action( 'wp_MEINTHEME_index_after_content' );
?>
Alles anzeigen