Log in or Register

Continue reading no show on excerpt

Home Forums General Discussion Continue reading no show on excerpt

This topic contains 5 replies, has 2 voices, and was last updated by  Zeaks 1 day, 6 hours ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10019

    JKNetDesign
    Member

    “Display Excerpts in Twenty Twelve Theme” works prefect but when I use the excerpt option on a post the Continue Reading link is not there. Notice the second post ‘How am I’
    http://nomastersrefuge.org/

    Another question: How do I control the number of posts display on the blog page but I only want 1 visible on each category page?

    In relation to the last question: How can I display 1 post from each category on the blog page. ik only want each recent post to be displayed.

    #10020

    Zeaks
    Member

    If you’ve created a manual excerpt, I believe you need to use a <!– more –> tag to show a continue reading link and the theme must support it.

    You can change the number of posts displayed on the index by visiting Settings > Reading

    To display 1 post from each category, you will need to create a custom loop and page template to display 1 post from each category on the blog page. I’d have to look into it more myself before I could begin to tell you how to do it but here’s a few articles that may help.

    Here’s a stackexchange post that explains how, you’ll need to be familiar with php http://stackoverflow.com/questions/3264323/how-do-i-get-only-1-post-from-each-category-in-wordpress

    Here’s another post i found through Google, I haven’t tried it http://eisabainyo.net/weblog/2010/03/10/display-5-latest-posts-in-each-category-in-wordpress/ if it works, you can set the number of posts to 1 instead of 5.

    #10024

    JKNetDesign
    Member

    I know of the Readings setting but it applies to both index and category pages.
    Do I add something in category.php to force alllow 1 post?

    For the 1 post per category on index page question:
    We’re getting close but here’s the specifics of this clients request:
    1. It needs to use the same code from your Display Excerpts post because we like that layout and functionality

    2. However, instead of all recent posts, it would display the 1 recent post from that category and so this for each category. If a new category is added it needs to included in the array.

    The StackOverflow article targets sub categories and the other one is close but they have the actual category name in the code.

    This would be great to get the perfect code for the solution. That’s why I hope you can help because it will probably be an extension of you’re already awesome code.

    #10025

    Zeaks
    Member

    This isn’t really related to the article, but I took some time and messed around with it.

    This isn’t perfect, it’ll require a few CSS adjustments but it seems to be working as it’s supposed to.

    Create a new file call it category-page-template.php and copy this into it.

    You will have to select the number of posts you want displayed, it’s set to 5, and add your own categories to the list as commented in the code.

    After you do that, create a new page, select the category first post template, then visit Settings > Reading and select static page, then select the new page you just created.

    I used a simple Twenty Twelve child theme, if you’re using Twenty Plus pro the options will not all work with it.

    You’ll also have to change the content to use excerpts, I didn’t have time to change that.

    <?php
    /**
     * Template Name: First Post Category
     *
     * This template display the first post from each selected category.
     *
     */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    
    <!-- Latest from Each Category (add your own use commas to separate) -->
    <?php query_posts(
                array('category_name'=>"Uncategorized, test1, test2",
                'showposts'=>5,
                'order'=>DESC)
          ); ?>
    
    	<?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
    	
    	<!-- Entry Title -->
    		<header class="entry-header">
    			<?php the_post_thumbnail(); ?>
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>
    			<h1 class="entry-title">
    				<a>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</h1>
    			<?php endif; // is_single() ?>
    			<?php if ( comments_open() ) : ?>
    				<div class="comments-link">
    					<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
    				</div><!-- .comments-link -->
    			<?php endif; // comments_open() ?>
    		</header><!-- .entry-header -->
    
    		
    	<!-- Entry Content -->
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    
    	<!-- Entry Meta -->
    		<footer class="entry-meta">
    			<?php twentytwelve_entry_meta(); ?>
    			<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    		</footer>
    
            <?php endwhile; ?>
        <?php endif; ?>
    	<!-- End of Category Display -->
    		
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    #10026

    JKNetDesign
    Member

    This is almost perfect. Since you know my situation I hope you have time to take another look.
    Here’s a screen shot of my results on my server. http://jknetdesign.com/images/nmr.png

    This does not apply to modifying content.php anymore correct?
    If so, what code do we edit in this file?

    Do you know why the continue reading function is not applying?

    Also, how can I pull each category above each h1 title?
    I attempted but it’s just repeating one cat.

    I stripped the entry-meta on purpose.

    <?php
    /**
    * Template Name: First Post Category
    *
    * This template display the first post from each selected category.
    *
    */

    get_header(); ?>

    <div id="primary" class="site-content">
    <div id="content" role="main">

    <!-- Latest from Each Category (add your own use commas to separate) -->
    <?php query_posts(
    array('category_name'=>"WordCraft, Poetry, Opinion, Karma, Zen Shin Progress",
    'showposts'=>5,
    'order'=>DESC)
    ); ?>

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    <!-- Entry Title -->
    <header class="entry-header">
    <?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?>
    <?php if ( is_single() ) : ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>
    <?php else : ?>

    <h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>

    <h1 class="entry-title">
    " title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>
    </h1>

    <?php endif; // is_single() ?>
    <?php if ( comments_open() ) : ?>
    <div class="comments-link">
    <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
    </div><!-- .comments-link -->
    <?php endif; // comments_open() ?>
    </header><!-- .entry-header -->

    <!-- Entry Content -->
    <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->

    <?php endwhile; ?>
    <?php endif; ?>
    <!-- End of Category Display -->

    </div><!-- #content -->
    </div><!-- #primary -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    #10030

    Zeaks
    Member

    I’m not sure if you’re using manually or auto excerpts from my tutorial so I’ll explain both.

    Twenty Twelve shows a continue reading link when using the <– more –> tag. But we skip the_content section of the loop when using the tutorial on this site.

    Normally when the “more” tag is used in the_content, it adds the continue reading link to it for manually created excerpts.

    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>

    When using the tutorial to add auto excerpts, it uses

    <?php the_excerpt(); ?>

    Then the continue reading link is added through a function.

    I don’t think you can use both.

    If you want to show auto excerpts in that template, change the_content to the_excerpt then add this to functions.php

    /* remove the ... from excerpt and change the text*/
    function change_excerpt_more(){
       function new_excerpt_more($more) {
            return '<span class="continue-reading"><a>ID) . '">  Continue Reading →</a></span>';
       }
       add_filter('excerpt_more', 'new_excerpt_more');
    }
    add_action( 'after_setup_theme', 'change_excerpt_more' );

    This should show the category title, style as needed.

    <h1><?php
    	foreach((get_the_category()) as $category) {
    	echo $category->cat_name . ' ';
    	}
    ?></h1>

    I’m not sure what you mean when you asked “This does not apply to modifying content.php anymore correct?
    If so, what code do we edit in this file?”

    That’s all the time I can spend on this template, if you have other questions about modifying the loop you should ask on wordpress.org

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Log in or Register