Make One Category Display Full Posts in Thesis Theme

July 19, 2010 at 1:42 pm by

Update: Seems like this doesn’t work with the latest version of thesis. If you get it working, let me know.

Got a request from a client to have a specific category page on their WordPress blog running the Thesis theme show full posts (vs. excerpts) for just one category. So I’m going to figure it out and write the steps here for the benefit of humanity.

First, to be clear, I’m not talking about changing ALL CATEGORY PAGES from excerpts to full posts. That can be done easily through the Thesis Display Options. You would change the “Posts” display options to “display full content” and the “Archives” display options to “same as home page”.

What I want to do is show excerpts on every category page except one. You do this by settings up a custom category theme, and Thesis has its own way to do that. A custom category theme wasn’t optimal for this install, so I need to do something different. It’s good to have different ways of doing things. Maybe my method below works for you too.

Here’s what we’re going to do.

  1. Use the “thesis_hook_before_post_box” hook to check the current category and if it is the “Quick Takes” category, change the $thesis['display']['archives']['style'] value to “content”.
  2. Use the “thesis_hook_after_post_box” hook to change the $thesis['display']['archives']['style'] value back to what it was before we tweaked it.

Sounds complicated, but it’s only a few lines to add to the /custom/custom_functions.php file in your Thesis theme folder.

function quicktakes_fullpost_setup()
{
	$target_category = "Quick Takes";
 
	//saving the global archives display setting so we can revert later
	global $thesis, $saved_thesis_display_archives_style;
	$saved_thesis_display_archives_style = $thesis['display']['archives']['style'];
 
	//checking the category, if it's the target category, then set the display to full post
	$current_category = single_cat_title("", false);
	if($current_category == $target_category)
		$thesis['display']['archives']['style'] = "content";
 
}
function quicktakes_fullpost_cleanup()
{
	//we're setting the display archives style back to what it was before we tweaked it
	global $thesis, $saved_thesis_display_archives_style;
	$thesis['display']['archives']['style'] = $saved_thesis_display_archives_style;
}
add_action('thesis_hook_before_post_box', 'quicktakes_fullpost_setup');
add_action('thesis_hook_after_post_box', 'quicktakes_fullpost_cleanup');

Be sure to change the $target_category variable to the title of the category you want to change.

If you want to do the inverse of this, which would be to show the excerpt on just one category page and update show the full post on all others, you would:

  1. Change the Thesis Display Options for posts to “display full post content”
  2. Change the Thesis Display Options for archives to “same as your homepage”
  3. Then adjust line 12 in the code above to set the style to “excerpts” instead of “content.

I hope this helps. Let me know if you have any questions about this or similar customizations for Thesis.

10 Responses to “Make One Category Display Full Posts in Thesis Theme”

  1. Mark says:

    I got excited when I found this, but it didn’t work for me.

  2. admin says:

    Mark and everyone. I should note that I’ve only used this on Thesis 1.5.1 so far. It might not be compatible with earlier or later version.

    I’m going to follow up with you by email Mark to figure out what your issue may be.

    • Did not work for me either! I am using Thesis 1.7

    • FYEO – Here is the code:

      function submitguestpost_fullpost_setup()
      {
      $target_category = “Submit Guest Post”;

      //saving the global archives display setting so we can revert later
      global $thesis, $saved_thesis_display_archives_style;
      $saved_thesis_display_archives_style = $thesis['display']['archives']['style'];

      //checking the category, if it’s the target category, then set the display to full post
      $current_category = single_cat_title(“”, false);
      if($current_category = $target_category)
      $thesis['display']['archives']['style'] = “content”;

      }
      function submitguestpost_fullpost_cleanup()
      {
      //we’re setting the display archives style back to what it was before we tweaked it
      global $thesis, $saved_thesis_display_archives_style;
      $thesis['display']['archives']['style'] = $saved_thesis_display_archives_style;
      }
      add_action(‘thesis_hook_before_post_box’, ‘submitguestpost_fullpost_setup’);
      add_action(‘thesis_hook_after_post_box’, ‘submitguestpost_fullpost_cleanup’);

  3. Dylan Deans says:

    Hi there,

    I tried your piece of text, though I didn’t have any luck. I’m using thesis 1.8. I cut and paste the code in my php between the two sample comments that initially come with the php file. I changed the target category to the correct category on my site. Do you know how I might get this to work in 1.8? Unfortunately I don’t have much coding experience.

    • admin says:

      Yeah doesn’t work in newer versions. I don’t have time to parse it, but if someone does, I’ll post the new code.

  4. The Sun says:

    It took me 2 days to solve this in Thesis 1.8 so I hope my code can help others:

    // custom categories to display full posts
    class my_loops extends thesis_custom_loop {
    function category() {

    if(is_category(14)) {

    // Default sort order (by date) is correct
    // But we want to change the HTML output

    // This creates standard Thesis HTML content blocks that
    // will automatically pick up Thesis styles
    thesis_archive_intro();
    echo ” . “\n”;
    echo ‘ ‘ . “\n”;
    echo ‘ ‘ . “\n”;

    // Here’s an actual WordPress Loop!
    while(have_posts()) { // This is standard WordPress
    the_post(); // Standard WordPress, sets up global variables

    // Output our notices with custom HTML
    echo ‘ ‘ .
    get_the_title() . ‘
    — ‘ .
    get_the_time(get_option(‘date_format’)) . “\n” .
    get_the_content() . “\n”;
    }

    // This closes the HTML blocks we opened
    echo ” \n”;
    echo ” \n”;
    echo “\n”;
    }
    else { // For all other categories

    // we’re happy with the default HTML output, so delegate the rest
    thesis_loop::category();
    }
    }
    }
    $loopty_loop = new my_loops;

    More details: http://diythemes.com/thesis/rtfm/custom-loop-api/

  5. serge says:

    Hi, nice approach. But a bit old. (Sorry)

    Use global $thesis_design; instead $thesis, to see the exact values you need you may lookup while on design options page using firebug (search for checkbox names in page HTML)

    I’ve posted similar function on diythemes forum

    Glad to meet thinking people over here,
    Cheers
    Serge

    • Beth says:

      Basic question, but where do I put the code that The Sun provided? thesis_hook_before_post_box? do I need to remove anything?

Leave a Reply

* Required
* Required, Private