1

I'm working on a website that I initially coded from scratch, but am now integrating wordpress with it because my client wants a backend.

Here's my problem, I'm using index.php for the main blog posts (which so far is working ok). But what I want to do is have just an excerpt of the posts (a brief summary) and then I want users to be able to click the 'read more' link in order to be taken a full page of that particular article/post (which I assume would be the single.php (if I'm not mistaken).

So here we go, here is the code I have for the main blog page (ie index.php - I'm only including the php code that's relevant here not the whole page):

<div id="content">              
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="vertical-align: text-top; padding-right: 20px;"><h1>Blog</h1></td>
<td style="vertical-align: text-top; padding-left: 20px;">
<h1>Archives</h1>
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>   
<?php wp_get_archives( 'type=monthly&format=option&show_post_count=1' ); ?>
</select>
</td>
<tr>
<td style="padding-right: 20px;">                   
<?php 
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('posts_per_page=5' . '&paged=' . $paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<div style="background-color: #fff; margin-top: 0px; padding: 20px 20px 20px 20px; border-color: #819cc7; border-style: solid; border-width: thin;">
<h2><a href="<?php $permalink = get_permalink( $id ); ?>"><?php the_title(); ?></a></h2>
<p><?php the_post_thumbnail(); ?></p>
<p><?php the_content( $more_link_text , '' , $more_file ); ?></p>
<p><?php _e('Filed under&#58;'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><p>
<p><?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> <?php edit_post_link('Edit', ' &#124; ', ''); ?>
<p>Date posted: <?php the_date(); ?></p>
<!--Don't know if I need the two lines below 
<p><?php //get_post_permalink(); ?></p>
-->
</div>
<p><?php endwhile; ?></p>
<?php $wp_query = null; $wp_query = $temp; ?>
</td>
<td style="padding-left: 20px;">&nbsp;</td>
</tr>
</table>
</div>

And this is the code I have for my single.php page:

<?php get_header(); ?>
    <section>
        <article id="white_bg">
            <div class="content_border">
                <div id="content">
                <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <p><?php the_post_thumbnail(); ?></p>
                <p><?php the_content(); ?></p>
                <p><?php _e('Filed under&#58;'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?></p>
                <p><?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> <?php edit_post_link('Edit', ' &#124; ', ''); ?></p>
                <br />
                <?php comments_template(); ?>
                <?php endwhile; ?>
                <div>
                <?php previous_post_link('< %link') ?> <?php next_post_link(' %link >') ?>
                </div>
                <?php endif; ?>
            </div>
            </div>
        </article><!--end main article-->
    </section><!--end main content section-->
<?php get_footer(); ?>    

I want people to be able to see the summarized article/post and click the read more link to be taken to single.php where they can view the full article/post and comment if they like.

1
  • Hi Daniel, First off...thank you for taking the time to read my question and answer it. I actually did attempt to use 'the_excerpt' and it worked fine. But my problem is that when people click on the 'read more' link using 'the_excerpt' in the coding, the link does not take the user to an alternate page which would display the entire article. Instead, if you hover over the 'read more' link, it's linking to the same page you're already on. I'm sorry my question wasn't more clear. Any additional help would be greatly appreciated. Thank you! Commented Mar 3, 2012 at 0:25

1 Answer 1

0

Where you see the_content() if you change it to the extract function called the_excerpt(). Which you can then add a permalink link after.

If you need any more on this visit http://codex.wordpress.org/Function_Reference/the_excerpt

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.