ThemeShaper Forums » Thematic

[closed]

full post and then excerpts on category pages

(25 posts)
  • Started 5 years ago by McGirl2008
  • Latest reply from helgatheviking
  • This topic is resolved
  1. On my category pages, I want to show one full post and then the rest of the list as excerpts.

    I tried creating a variable which I called $full_content:

    // CHANGE WHAT GETS EXCERPTS
    $full_content = false;
    function childtheme_content($content) {
    if ($full_content) {
    $content= 'full';
    } elseif (is_home() || is_front_page()) {
    $content= 'excerpt';
    } elseif (is_single()) {
    $content = 'full';
    } elseif (is_tag()) {
    $content = 'excerpt';
    } elseif (is_search()) {
    $content = 'excerpt';
    } elseif (is_category()) {
    $content = 'excerpt';
    } elseif (is_author()) {
    $content = 'excerpt';
    } elseif (is_archive()) {
    $content = 'excerpt';
    }
    return $content;
    }
    add_filter('thematic_content', 'childtheme_content');

    and then using that variable in the categoryloop:

    // The Category Pages
    function childtheme_categoryloop() {
    $count = 0;
    while (have_posts()) : the_post();
    $count++;
    if ($count <= 1) { ?>
    <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">
    <?php thematic_postheader(); ?>
    <div class="entry-content">
    <?php $full_content = true;
    thematic_content();
    $full_content = false; ?>
    </div>
    <?php thematic_postfooter(); ?>
    </div><!-- .post -->
    <?php } else {
    ?>
    <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">
    <?php thematic_postheader(); ?>
    <div class="entry-content">
    <?php
    $full_content = false;
    thematic_content(); ?>
    </div>
    <?php thematic_postfooter(); ?>
    </div><!-- .post -->
    <?php } ?>
    <?php endwhile;
    $full_content = false;
    }
    add_action('thematic_categoryloop', 'childtheme_categoryloop');

    I could see my changes to the loop, but no matter how I mess with this the category pages only show all-full, or all-excerpt. I have tested and the childtheme_categoryloop *can* definitely pull in different content for the if/else loop (if I use plaintext).

    Any help is VERY much appreciated!! Thanks!

    Michelle

    Posted 5 years ago #
  2. Hi Michelle,

    thematic_content() wasn't built for this purpose. You can use it to define one behavior for a certain category, archive type or whatever.

    To realize your request you need to remove the action thematic_category_loop. Then you can hook your own child_category_loop to thematic_categoryloop. In your function you can use the counter like above. But you need to use either the_content() for your first post or the_excerpt() for the rest.

    Cheers,

    Chris

    Posted 5 years ago #
  3. Thank you so much, Chris!!! Head-slapping here - why o why was I making it so complicated? Thanks for your very sensible suggestions. :)

    Posted 5 years ago #
  4. Hi Chris, I was wondering if there is a way to simply have full posts show in the category pages instead of excerpts. I have an art blog and the category pages leave a lot to be desired because images and videos do not show up in excerpts. Is there a work around for this?

    Posted 4 years ago #
  5. Hi,

    try this code in your child theme's functions.php:

    function childtheme_content($content) {
    	if (is_category()) {
    		$content= 'full';}
    	return $content;
    }
    
    add_filter('thematic_content', 'childtheme_content');

    Chris

    Posted 4 years ago #
  6. lqunta
    Member

    @All, @Chris

    Yet again, I'm greatful to have found yet another useful post.

    Pardon me if I sound lost...for each category, does one have to create a 'category page'?

    I would like to achieve the following on a category page :
    - Have the current category's description first
    - Have a listing of the posts in the current category [i.e. Thumbnail floated left, The Post [Title, Post Meta[Category Only], and Excerpt] floated right.

    Will the code above achieve this?

    Cheers, and Thanks

    Posted 4 years ago #
  7. Howdy- lqunta

    All that the function above will do is display full posts instead of excerpts on category all archive pages. This function affects the code for the category.php template in the thematic theme which is inherited and used by your child theme.

    I'm not sure what you mean by "create a category page" Do you mean to say "category page template"

    Replacing the thematic_category_loop could do the things that you wish but the code in Chris's will not do it. here is a discussion that covers replacing the thematic_category_loop

    http://forums.themeshaper.com/topic/filter-the-category-loop-for-one-specific-category#post-6725

    -Gene

    Posted 4 years ago #
  8. lqunta
    Member

    Hey Gene,

    Thanks for the above pointer. Possibly, to explain myself a little, I have this 'peculiar' setup.

    - Home page which should only display the latest 5 posts
    - Categories [e.g. My Articles], which have Sub-Categories [e.g. Fictional Stories, Poems, Tips]
    - As such, I would like, when one clicks on a category, e.g. Fictional Stories, he/ she should, first of all, read about the category [category description], then, a listing of the current category's content as mentioned above, limited to x number of articles.

    I hope this elaborates further what setup I'm trying to achieve.

    Cheers
    LQunta

    Posted 4 years ago #
  9. lqunta-

    Ahh.. This sounds like a good twist for the discussion over here:

    http://forums.themeshaper.com/topic/posts-inside-the-pages-and-subpages/page/2

    -Gene

    Posted 4 years ago #
  10. lqunta
    Member

    @Gene,

    Sure it is. Trying to have a go as well.

    Cheers

    Posted 4 years ago #
  11. lqunta-

    Sorry to be long in returning to this discussion. You may have already resolved this but in case your still having problems with it, There are a few things I'd like to point out. A good bit of what you mentioned above is already done by default by Thematic or can be set in the WP admin.

    -To set the no. of posts shown on the home page log in to the WordPress admin and go to Settings>Reading>Blog pages show at most ? posts.

    -As far as the category discription goes, if you have a description entered for the category It will appear in a div class"archive-meta" beneath the h1 by default with Thematic.

    -As far as having the category archives show an x no. of posts. The cat archives will show the same no. of posts as set in the WP admin in reading settings for blog pages.

    If you wanted a diffent post limit on archive pages from that set in the WP admin reading settings then you could use this code and set the $post_limit to suit your needs.

    function my_cat_archive_post_limit() {
    
    		$post_limit = '2';
    
        	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
         	query_posts('cat=' . get_cat_ID() . '&showposts=' . $post_limit . '&paged=' . $paged );
        	$wp_query->is_archive = true; $wp_query->is_home = false;
    }
    add_action('thematic_above_categoryloop','my_cat_archive_post_limit');

    -Gene

    Posted 4 years ago #
  12. Chris, I didn't have any luck with the code you provided me. I know very little about php so chances are that I am doing something wrong. I copied and pasted your code exactly as it was into my functions.php file. I wasn't sure where it should go so i tried several different spots, but to no avail. Is there a certain line where it needs to go?

    I'm using Powerblog.

    Posted 4 years ago #
  13. stengl
    Member

    The solution Chris provided worked just fine for me:

    function childtheme_content($content) {
    if (is_category()) {
    $content= 'full';}
    return $content;
    }

    add_filter('thematic_content', 'childtheme_content');

    I additionally used it with is_tag().

    The only thing missing now is the search results page. I somehow can't figure out, how to get full posts displayed there. Any ideas?

    Posted 4 years ago #
  14. Have you tried http://codex.wordpress.org/Conditional_Tags#A_Search_Result_Page ?

    Chris

    Posted 4 years ago #
  15. stengl
    Member

    Thanks Chris, this is exactly what I was looking for.

    Posted 4 years ago #
  16. Laraine
    Member

    I've succeeded in implementing a child theme with a style.css in my child theme folder. But when I copy the sample functions.php into the child theme folder, a lot of errors occur.

    Primarily: Warning: Cannot modify header information -- headers already sent out by...
    then a series of other sources such as wp-login.php and pluggable.php

    I'm in this thread because I would like to add pictures to the archive listing as described above by dstntmbrk but need the functions.php to do it.

    Here is the address:

    http://www.larainearmenti.com/blog/

    thank you very much for your guidance.

    Posted 4 years ago #
  17. Which sample functions.php do you mean? The one from the directory thematicsamplechildtheme?

    Chris

    Posted 4 years ago #
  18. Laraine
    Member

    Yes: functions.php in the folder thematicsamplechildtheme

    <?php

    //
    // Custom Child Theme Functions
    //

    // I've included a "commented out" sample function below that'll add a home link to your menu
    // More ideas can be found on "A Guide To Customizing The Thematic Theme Framework"
    // http://themeshaper.com/thematic-for-wordpress/guide-customizing-thematic-theme-framework/

    // Adds a home link to your menu
    // http://codex.wordpress.org/Template_Tags/wp_page_menu
    //function childtheme_menu_args($args) {
    // $args = array(
    // 'show_home' => 'Home',
    // 'sort_column' => 'menu_order',
    // 'menu_class' => 'menu',
    // 'echo' => true
    // );
    // return $args;
    //}
    //add_filter('wp_page_menu_args','childtheme_menu_args');

    ?>

    Posted 4 years ago #
  19. Laraine
    Member

    Chris,

    Thank you for noticing my request for help. The code you provided above solves the problem of having pictures displayed when "Categories" is selected. Would you provide instructions that work similarly for "Archives" ?

    Thanks!

    Laraine

    Posted 4 years ago #
  20. Hi Laraine,

    just change is_category to is_archive .. this will include all Category, Tag, Author and Date based pages.

    Chris

    Posted 4 years ago #
  21. Laraine
    Member

    Fantastic! Everything works...

    Also, thanks for the scrambled eggs video on your site. Can't wait to try that, too!

    Thank you so much for solving my problem.

    Laraine

    Posted 4 years ago #
  22. Hello forum!

    function childtheme_content($content) {
    if (is_archive()) {
    $content= 'full';}
    return $content;
    }

    is not working for me - all archive pages are shown as excerpts. Can anyone tell me what's wrog there?

    Posted 4 years ago #
  23. guyk
    Member

    Hello

    Thanks for this i use it and its right
    function childtheme_content($content) {
    if (is_category('8')) {
    $content= 'full';}
    return $content;
    }
    add_filter('thematic_content', 'childtheme_content');

    but i want just the first post content open in the category 8 and the rest with excerpt...
    thanks a lot if you answer

    Thanks

    guy

    Posted 4 years ago #
  24. grrreat, thanks for code sample :-)

    and now to answer the original question with said sample - this modification will show first post on category archive as full and rest as excerpts:

    // category pages with full content
    
    function childtheme_content( $content ) {
    	global $loopcounter;
    	if ( is_category() & !$loopcounter ) {
    		$content= 'full';
    		$loopcounter++;
    	}
    	return $content;
    }
    
    add_filter( 'thematic_content', 'childtheme_content' );
    Posted 2 years ago #
  25. cool share. i will have to check that out, i've been wondering how to do that myself.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.