• Is it possible to set some post to show the entire post in a blog and some only to show the excerpt? I know how to set the global setting (so either all posts showing entire post or all posts showing excerpts). But I’d like to know if I can control this at a post by post level.

    OR, is it possible to set posts that has something in the “excerpt” field to show excerpt, otherwise, show the entire post?

    Thanks for any help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You actually could do something like this using the Custom Fields section and adding an Excerpt name and a true/false value. Then in the theme files you could do an if/else statement to check if the Excerpt value is set to true then display the post as an excerpt.

    Were you just looking for some guidance because that should work. If you were looking for the actual code then that is a whole other story ??

    OR, is it possible to set posts that has something in the “excerpt” field to show excerpt, otherwise, show the entire post?

    Yes, it is:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post();
    			echo '<h2>' . $post->post_title . '</h2>';
    			if (empty($post->post_excerpt))
    				the_content();
    			else
    				echo '<p>' . $post->post_excerpt . '</p>';
    		endwhile; ?>

    That works too ??

    Thread Starter phuile

    (@phuile)

    Thanks for the explanation and the codes. I am just starting out so I will have to see how I go with the code. I have only done really really simple things like changing the code so that the post show what’s in the exceprt field instead.

    I guess this code replaces the lines that control what should show?

    I have this at the moment on my theme’s index.php:

    <!– article-content –>

    <?php if (is_search()) the_excerpt(); else the_excerpt(__(‘Read the rest of this entry »’, ‘kubrick’)); ?>
    <?php if (is_page() or is_single()) wp_link_pages(array(‘before’ => ‘<p>Pages: ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>

    <!– /article-content –>

    So do I replace the first <?php ,,, line with the one you suggested? My apologies, I have been designing themes but have only just very recently need to adj codes, so I need a lot of help. But I am trying to learn!

    Thanks again.

    The code I pasted is general. Little doubt it will fit your specific code without modification. Probably you will have to change the index.php file, somewhere around the_content function. If there is something like this:

    <div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>

    you can replace the line:

    <?php the_content('Read the rest of this entry &raquo;'); ?>

    with

    <?php if (empty($post->post_excerpt))
    		the_content();
    			else
    				echo '<p>' . $post->post_excerpt . '</p>';
    ?>

    I guess (I don’t have the sources of the theme you use).

    Thread Starter phuile

    (@phuile)

    Thank you so much for the help. This is what I have at the moment (below) … I am trying to figure it out … which I am having some difficulties with since I don’t know what everything means yet, just some things. Thanks for any help!

    <?php get_header(); ?>
    <div class=”art-content-layout”>
    <div class=”art-content-layout-row”>
    <?php include (TEMPLATEPATH . ‘/sidebar1.php’); ?><div class=”art-layout-cell art-content”>

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class=”art-post”>
    <div class=”art-post-body”>
    <div class=”art-post-inner art-article”>
    <h2 class=”art-postheader”>
    ” rel=”bookmark” title=”<?php printf(__(‘Permanent Link to %s’, ‘kubrick’), the_title_attribute(‘echo=0’)); ?>”>
    <?php the_title(); ?>

    </h2>
    <div class=”art-postcontent”>
    <!– article-content –>

    <?php if (is_search()) the_excerpt(); else the_content(__(‘Read the rest of this entry »’, ‘kubrick’)); ?>
    <?php if (is_page() or is_single()) wp_link_pages(array(‘before’ => ‘<p>Pages: ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>

    <!– /article-content –>
    </div>
    <div class=”cleared”></div>

    </div>

    <div class=”cleared”></div>
    </div>
    </div>

    <?php endwhile; ?>
    <?php
    $prev_link = get_previous_posts_link(__(‘Newer Entries »’, ‘kubrick’));
    $next_link = get_next_posts_link(__(‘« Older Entries’, ‘kubrick’));
    ?>
    <?php if ($prev_link || $next_link): ?>
    <div class=”art-post”>
    <div class=”art-post-body”>
    <div class=”art-post-inner art-article”>

    <div class=”art-postcontent”>
    <!– article-content –>

    <div class=”navigation”>
    <div class=”alignleft”><?php echo $next_link; ?></div>
    <div class=”alignright”><?php echo $prev_link; ?></div>
    </div>

    <!– /article-content –>
    </div>
    <div class=”cleared”></div>

    </div>

    <div class=”cleared”></div>
    </div>
    </div>

    <?php endif; ?>
    <?php else : ?>
    <h2 class=”center”><?php _e(‘Not Found’, ‘kubrick’); ?></h2>
    <p class=”center”><?php _e(‘Sorry, but you are looking for something that isn’t here.’, ‘kubrick’); ?></p>
    <?php if(function_exists(‘get_search_form’)) get_search_form(); ?>
    <?php endif; ?>

    </div>

    </div>
    </div>
    <div class=”cleared”></div>

    <?php get_footer(); ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Showing entire post or excerpt – post by post control?’ is closed to new replies.