Forums

How to collapse/expend posts once entering categories? (17 posts)

  1. yegor.money.mag
    Member
    Posted 9 months ago #

    Hello everybody,

    I'm new in blog creation.

    My passion is potato recipes. I try to make my blog user friendly but I experience some issues. It's fine that on the main page people can see all recent posts. However, once they click on the category, I want a list of all the recipes so people can click on the recipe and than the poste will open. It's hard to find something when all posts are open.

    I tried the collapse category plugin, but it's ugly. How can I manege my problem.

    Please help me here or leave me the answer on my blog at http://easyfastpotatorecipes.com/

    Thank you for help

  2. rochee_jd
    Member
    Posted 9 months ago #

    Hi, you could just use the_excerpt(); rather than the_content(); so that not the whole content is displayed when a category is clicked.

  3. yegor.money.mag
    Member
    Posted 9 months ago #

    Sorry, I'm a total newbe. How I do so.

    If possible step by step.

    Thank you very much!

  4. yegor.money.mag
    Member
    Posted 9 months ago #

    To be more precise, I use the Twenty Eleven 1.2 Theme.

    What part I should edit? the category.php?

  5. yegor.money.mag
    Member
    Posted 9 months ago #

    I found this information:

    Enforce excerpts
    To enforce WordPress to show excerpts for all articles we have to modify the content.php of twenty eleven.
    Find the following code:

    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
    <?php the_content( __( 'kompletter Artikel >> '. the_title_attribute (array('echo' => 0) ) .' <span class="meta-nav">→</span>', 'twentyeleven' ) );?>
    And now replace it with the following snipped. Notice that only the last line has changed.

    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
    <?php the_excerpt();?>
    That’s it. Now for all posts the article itself should be hidden and an excerpt should be shown instead.

    at: http://zeaks.org/enforce-and-customize-read-more-for-twenty-eleven-guest-post/

    But it modifyes all the posts everywhere.

    What I need, it's when people click on a particular category, it shows a list of only titles of the posts. The main page must stay as is.

    Getting complicated now, thanks for helping

  6. rochee_jd
    Member
    Posted 9 months ago #

    Hi, I'm not an expert too but maybe this article could help : http://vandelaydesign.com/blog/wordpress/category-hacks/

    I'm also trying to do this on my local WordPress so that I could somehow help you.. :)

  7. analogrithems
    Member
    Posted 9 months ago #

    Another way to do it that will give you much more control is to make use of WordPress custom Menu's under Appearance->Menus Create a menu call it navigation make all of your categories 1st level and then add your individual pages and use the drag and drop feature to indent them. This will give you a staggered affect in your site.

    -Analog

  8. rochee_jd
    Member
    Posted 9 months ago #

    That's a great idea... :D

  9. analogrithems
    Member
    Posted 9 months ago #

    Thanks, I specialize in those ;)

    i forgot to add that if you want the menu to show up in your sidebar use the custom menu widget under Appearance->Widgets

  10. zeaks
    Member
    Posted 9 months ago #

    You could create a category template for the specific category. I did the same thing you're doing with my code snippets page a while ago. I only wanted the title to display on category pages.

    Copy category.php and rename it category-12.php where 12 is the number of your category (can find that by visiting categories in admin and hovering over the category name), then just edit it however you want, removing the content of the post in your case.

  11. yegor.money.mag
    Member
    Posted 9 months ago #

    Thank you guys for help, your advices are probably great but too complicated for me. I tried to apply them ( not all at the same time) but always get stuk somewhere. I will continue to try to find a step by step tutorial for dumies :)

  12. rochee_jd
    Member
    Posted 9 months ago #

    Hi again, just to add something, though I don't know if this might help.. I used a plugin called "wordpress-category-post" it lets you diplay the title of each post of each category...

    Here's how:
    1. Install the plugin.(Activate it of course)
    2. Open your category.php file.
    3. Find this code (in the twentyeleven theme):

    <?php
    /* Include the Post-Format-specific template for the content.
     * If you want to overload this in a child theme then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead. */
        get_template_part( 'content', get_post_format() );
    ?>

    4. delete or comment out the get_template_part('content', get_post_format() );
    5. Replace it with the plugin function which is:

    if (is_category(1)) {
    wp_cat_posts(1); }

    Where 1 is the ID of your category. You can see the number of your category when you click it and look at the address bar which is something like this:
    http://localhost/Plugins/?cat=1
    here, the Category ID is 1...
    so if you want to make this to all categories, just copy and paste the function and change the category id.

    I hope this helps... :)

  13. yegor.money.mag
    Member
    Posted 9 months ago #

    I installed:

    Category Posts Widget
    Version 3.2

    I did:
    3. Find this code (in the twentyeleven theme):

    I understand step 4 but not the step 5.

    I have like 13 categories. when I open in browser let say:
    http://easyfastpotatorecipes.com/category/all_about_potatoes/

    I don't see the category ID. Or I should look eslwhere.

    If I go on dashboard it looks like this:
    http://easyfastpotatorecipes.com/wp-admin/plugins.php

    I will try to find more info about he category ID.

  14. keesiemeijer
    moderator
    Posted 9 months ago #

    replace get_template_part('content', get_post_format() ); with :

    if (is_category(1)) {
    wp_cat_posts(1); }

    To find a categorie ID go to wp-admin > Posts > Categories and click on the category name that you want the ID of. The url of the page you are on will show what the category id is. eg wp-admin/edit-tags.php?action=edit&taxonomy=category&post_type=post&tag_ID=14 means the category ID is 14

  15. rochee_jd
    Member
    Posted 9 months ago #

    I see that it just displays the category name so we must get the ID of that category name and here is how:

    $id = get_cat_id('Uncategorized');
    if (is_category($id)) {
       wp_cat_posts($id); }

    where "Uncategorized" is the category name. Just copy and Paste this code and replace the category name each time you add a category.. I'm sorry this is the way I do it so it's kinda' long. Loops are really not my thing.

  16. yegor.money.mag
    Member
    Posted 8 months ago #

    Hi guys,

    Thank you very much for your help. I'm to newbe to understand what you explained to me. A friend of mine helped me with my issue.
    He is the owner of http://www.controlweightdancing.com/

    He worked with my content.php and did some changes. I would like to point the exact changes but it's to hard for me because I don't understand them. So if someone wise will do it, it would be great.

    Here is my entire content.php

    <?php
    /**
    * The default template for displaying content
    *
    * @package WordPress
    * @subpackage Twenty_Eleven
    * @since Twenty Eleven 1.0
    */
    ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
    <?php if ( is_sticky() ) : ?>
    <hgroup>
    <h2 class="entry-title">" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></h2>
    <h3 class="entry-format"><?php _e( 'Featured', 'twentyeleven' ); ?></h3>
    </hgroup>
    <?php else : ?>
    <h1 class="entry-title">" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></h1>
    <?php endif; ?>

    <?php if ( 'post' == get_post_type() ) : ?>
    <div class="entry-meta">
    <?php if (!is_category() ) : ?>
    <?php twentyeleven_posted_on(); ?>
    <?php endif; ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>

    <?php if ( comments_open() && ! post_password_required() ) : ?>
    <div class="comments-link">
    <?php comments_popup_link( '<span class="leave-reply">' . __( 'Reply', 'twentyeleven' ) . '</span>', _x( '1', 'comments number', 'twentyeleven' ), _x( '%', 'comments number', 'twentyeleven' ) ); ?>
    </div>
    <?php endif; ?>
    </header><!-- .entry-header -->

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php elseif ( !is_category() ) : ?>
    <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    <footer class="entry-meta">
    <?php $show_sep = false; ?>
    <?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
    <?php
    /* translators: used between list items, there is a space after the comma */
    $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
    if ( $categories_list ):
    ?>
    <?php if (!is_category() ) : ?>
    <span class="cat-links">
    <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyeleven' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
    $show_sep = true; ?>
    </span>
    <?php endif; ?>
    <?php endif; // End if categories ?>
    <?php
    /* translators: used between list items, there is a space after the comma */
    $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    if ( $tags_list ):
    if ( $show_sep ) : ?>
    <span class="sep"> | </span>
    <?php endif; // End if $show_sep ?>
    <span class="tag-links">
    <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyeleven' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );
    $show_sep = true; ?>
    </span>
    <?php endif; // End if $tags_list ?>
    <?php endif; // End if 'post' == get_post_type() ?>

    <?php if ( comments_open() && !is_category() ) : ?>
    <?php if ( $show_sep ) : ?>
    <span class="sep"> | </span>
    <?php endif; // End if $show_sep ?>
    <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?></span>
    <?php endif; // End if comments_open() ?>

    <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
    </footer><!-- #entry-meta -->
    </article><!-- #post-<?php the_ID(); ?> -->

  17. yegor.money.mag
    Member
    Posted 8 months ago #

    If you understand the changes that he made, maybe show them to others.

    To remind you, what I wanted is to see only titles when open category.

    For better reference, wisit my blog easyfastpotatorecipes.com and click on a category to see what it looks like.

    Thank you all for help

Reply

You must log in to post.

About this Topic