• Meenimod

    (@meenimod)


    Hello,

    My blog page displays my posts, however instead of displaying the whole content of a post, I just want it to display an excerpt/summary/the first few lines, then a link to the whole post.

    I read up a lot on excerpts and the the_content() and the_excerpt() functions, but it just makes me more confused.

    Can someone please give me clear instructions on what to do?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Marvie Pons

    (@marviepons)

    I just want it to display an excerpt/summary/the first few lines, then a link to the whole post.

    You can just use the more quicktag button found above the Post Editing Area. You can Insert it at your desired cut-off point when editing a post.

    http://codex.wordpress.org/Customizing_the_Read_More

    Michael

    (@alchymyth)

    depends on your theme;

    please post the name and download link of your theme.

    if you like, you can also post a link to your site.

    Thread Starter Meenimod

    (@meenimod)

    You can just use the more quicktag button found above the Post Editing Area. You can Insert it at your desired cut-off point when editing a post.

    I don’t want to have to do it for every post. Is there a way other than to manually do it for every post?

    Thread Starter Meenimod

    (@meenimod)

    depends on your theme;

    please post the name and download link of your theme.

    if you like, you can also post a link to your site.

    I’m using twentytwelve theme.

    islamicvalues.co.uk

    Michael

    (@alchymyth)

    edit content.php in your child theme;

    change this line:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>

    to:

    <?php if ( is_search() || is_home() ) : // Only display Excerpts for Search and Posts Page ?>

    you could extend that to archives etc by including more conditional tags; http://codex.wordpress.org/Conditional_Tags

    Thread Starter Meenimod

    (@meenimod)

    edit content.php in your child theme;

    change this line:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    to:

    <?php if ( is_search() || is_home() ) : // Only display Excerpts for Sea

    yay that worked! thanks – btw do you know how I can edit the message “this entrey was posted in X on…” where X is the category? I want to remove X as I don’t have any categories.

    Michael

    (@alchymyth)

    in functions.php of your child theme, add:

    function twentytwelve_entry_meta() {
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    		$utility_text = __( 'This entry was posted on %1$s<span class="by-author"> by %2$s</span>.', 'twentytwelve' );
    
    	printf(
    		$utility_text,
    		$date,
    		$author
    	);
    }

    (untested)

    Thread Starter Meenimod

    (@meenimod)

    Before I try that, how do I make a copy of functions.php from twentytwelve theme to my child theme? Because what I have been doing before is when I want to copy a certain file, I would first open the original file of the parent theme (twentytwelve) in the editor from the dashboard, copy the whole content, create a new file on my desktop with the same name, paste the contents, then upload it to my child theme folder using FileZilla. But I found a post by you on another thread in which you said never do that as it can result in a fatal error, so I stopped doing it that way.

    Michael

    (@alchymyth)

    don’t copy functions.php into the child theme;

    just create a new empty functions.php, add <?php into the first line – nothing whatsoever before that- and possible add ?> into the last line;

    add the new code inbetween.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How do I add excerpt to a post?’ is closed to new replies.