Hello Wordpress People,
I wanted to ask how I can change the output for my search results in the code below the part <div class="entry"><?php the_content(); ?></div>
?
I want only to show the Page, Post or Category Title and the Text. But Text also only like 500 Charaters to show and then a link "read more".
Is there a way to get this done? Thanks for any help.
This is my code for search.php:
<div id="main">
<?php if (have_posts()) : ?>
<p class="info">Ihre Suchergebnisse für: <strong><?php echo $s ?></strong></p>
<?php while (have_posts()) : the_post(); ?>
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<div class="entry">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<p align="center"><?php next_posts_link('« Ältere Einträge') ?> | <?php previous_posts_link('Neuere Einträge »') ?></p>
<?php else : ?>
<div class="no-found">
<h3>Ups?! Wir konnten unter dem Begriff <span>"<?php echo $s ?>"</span> leider nichts finden.</h3>
<p>Kehren Sie bitte <a href="<?php bloginfo( 'url' ); ?>">zur Startseite</a> zurück.</p>
</div>
<?php endif; ?>
</div><!-- main -->
<div id="sidebar">
<?php get_sidebar(); ?>
</div><!-- sidebar -->
I'd probably just change the_content()
to the_excerpt()
instead. This will get you pretty close to what you're wanting.
you should use the_excerpt() function instant of the_content and use a link with read more(permalink).
Here the code :
<div class="entry">
<?php the_excert(); ?>
<a href="<?php the_permalink(); ?>">Read More</a>
</div>
also, you can follow this Question and answer here
Thanks