• Hello friends

    I would like to make my posts appear in preview format with the teaser line, part of the text, and a thumbnail of the image that is featured in the post.

    I dont know how to do this

    Thanks for your suggestions!

    Sebastian

Viewing 5 replies - 1 through 5 (of 5 total)
  • Use <?php the_excerpt(); ?> instead of <?php the_content(); ?>

    Thread Starter sebastianotero

    (@sebastianotero)

    Thanks! Im newb. Where do I paste that?

    I wanna do it “a la” search engine result. Example:

    https://search.yahoo.com/search?p=women+dancing&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-832

    That depends where you want to show it. If you want to show excerpts on your homepage you need to edit your index.php file. Find the line where it says <?php the_content(); ?> and place <?php the_excerpt(); ?> instead.

    mjfus

    (@mjfus)

    Can someone direct me on where to place ‘the_content’ tag? I’m trying to display the full text of a post on my homepage page using the code below:

    <?php
    global $more; // Declare global $more (before the loop).
    $more = 1; // Set (inside the loop) to display all content, including text below more.
    the_content();
    ?>

    I don’t know where to put this code, because I’m using a template that doesn’t have <?php the_content(); ?> or <?php the_excerpt(); ?>
    in the index.php file. All that’s in the index.php file is:

    <?php
    global $options;
    foreach ($options as $value) {
    if (get_settings( $value[‘id’] ) === FALSE) { $$value[‘id’] = $value[‘std’]; } else { $$value[‘id’] = get_settings( $value[‘id’] ); }
    }
    if($swift_magzine==’magzine’) include(‘layouts/magzine.php’);
    else include(‘layouts/blog.php’);
    ?>.

    1. Create a new PHP template page. Call it “Overview” or something like that.
    2. Past in the code found below.
    3. save the new file to your wp site
    4. Open your admin page. Create a page.
    5. click quick edit and select “overview” from the template drop down.

    Now this page will show all of your post within a category up to the <more> link.

    If you want this on your home page just add the script to your index page along with an if statement to check that this is the home page and skip the template part.

    in simple English this is what the code does:
    Search all posts (you can limit this to categories)
    Display the post.
    Limit the amount you show to stop when it sees the <!–more–> tag.

    *note the div tags are for styling the results

    <?php
    /*
    Template Name: Overview
    */
    ?>
    
    <?php
    query_posts('category_name=mycategory');
    
    global $more;
    // set $more to 0 in order to only get the first part of the post
    $more = 0; 
    
    // the Loop
    while (have_posts()) : the_post();
    ?>
    
    				<div class="container">
    				<!-- Display the Title as a link to the Post's permalink. -->
    						<a href="<?php the_permalink(); ?>">permalink</a>
    						<div id="title"><?php the_title(); ?></div>
    
    				<!-- Display the Post's Content in a div box. -->
    						<div class="entry">
    						<!-- the content of the post -->
    						<?php the_content('view full the article?'); ?>
    						</div>
    				</div> <!-- closes the first div box -->
    
    <?php
    endwhile;
    ?>

    Check out query_posts for more details

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I create Excerpt Previews’ is closed to new replies.