ThemeShaper Forums » Thematic

[closed]

Strip "more tag" from category view

(10 posts)
  • Started 4 years ago by bernd
  • Latest reply from flick
  • This topic is not resolved
  1. bernd
    Member

    Hi there,

    I use the "more tag" on my sticky posts. However, when in category view, I don't want the more tag to be displayed at all. Instead the full post should be displayed. I want this for all my categories but one, so one certain category should still show the "read more" link when in category view for this specific category.

    How to go about that?

    Thanks :)

    Posted 4 years ago #
  2. @bernd: If only one category needs the 'more' tag, I assume it's best to change the default category template to exclude this and show full posts; then create a custom template for that one category to show the 'more' tag.

    Posted 4 years ago #
  3. bernd
    Member

    Yep, I follow you. But my php skills are very poor, so what exactly would work in my category.php? Actually I don't need the more tag in any of the categories, so I just want to strip it completely when browsing in category view (multi-post-view).

    Here is my category template:


    <?php
    global $options;
    foreach ($options as $value) {
    if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
    else { $$value['id'] = get_option( $value['id'] ); }
    }
    ?>
    <?php get_header() ?>

    <div id="container">
    <div id="content">

    <?php thematic_page_title() ?>

    <?php thematic_navigation_above();?>

    <?php thematic_above_categoryloop() ?>

    <?php thematic_categoryloop() ?>

    <?php thematic_below_categoryloop() ?>

    <?php thematic_navigation_below();?>

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

    <?php thematic_sidebar() ?>
    <?php get_footer() ?>

    Posted 4 years ago #
  4. @bernd: My mistake there I'm afraid. Apologies. It turns out it's much easier just to filter the 'more...' tag. I assume you're using the default 'excerpts' for your category posts??

    If so, I think you can probably use a slight change to Chris' code for filtering the excerpt in your child theme functions.php:

    function excerpt_ellipse($text) {
       if(is_category()){
       return str_replace('[...]', '', $text);
       }else{
    	return $text;
    	}
    }
    add_filter('get_the_excerpt', 'excerpt_ellipse');

    So what this does is say, if it's a category template, replace [...] with nothing.
    But this shouldn't affect any other default templates that use the excerpt function (including e.g. Tags or Archives templates etc.)

    Hope this helps.

    Posted 4 years ago #
  5. bernd
    Member

    Thanks flick, but actually for my stick post I'm not using excerpts. Instead I use the more tag for those (and once i un-stick the post I remove the more tag).

    Now you've gotten me a step closer with your code, but can't quite figure it out yet.

    Posted 4 years ago #
  6. @bernd: I managed to completely disregard 'sticky posts' from your first post!

    Are you using a particular plugin for your sticky posts?

    Posted 4 years ago #
  7. bernd
    Member

    @flick: No, I'm just using the built-in Wordpress function for my sticky posts and style them via .css, here's what I use:

    .home #content .sticky {
    background:#e5ecf5;
    border:4px double #ccc;

    Now, in all my sticky posts I use the more tag, instead of excerpts, so I can cut off exactly where I want and then insert the more tag. I only want it this way in my sticky posts, but when one navigates to the category view, all more tags should be ignored and instead the full posts should be shown.

    Posted 4 years ago #
  8. @bernd: Thanks for clarifying. I did a quick search and came across this $more variable in the WordPress Codex.

    It says:

    If you set the $more variable to -1, the More tag will not be displayed. This can be useful in a "mullet loop". Like this:

    <?php global $more; $more = -1; //declare and set $more before The Loop ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); //begin The Loop ?>
    <?php
        if ($more == -1) { //do not use the more tag on the first one.
            the_content();
            $more = 0; //prevent this from happening again. use the more tag from now on.
        }
        else { //use the more tag
            the_content(__('Read more...'));
        }
    ?>
    <?php endwhile; //end of The Loop ?>

    So literally putting in a global $more; $more = -1; into the thematic_content filter (below) seems to work just fine for me - I often use 'more' tags for my front page posts as they are otherwise set to display in full.

    function fullpost_cat($content) {
    	if (is_category()) {
    		global $more; $more = -1; //declare and set $more before The Loop
    		$content= 'full';}
    	return $content;
    }
    
    add_filter('thematic_content', 'fullpost_cat');
    Posted 4 years ago #
  9. bernd
    Member

    That works like a charm! Thank you so much. :)

    Posted 4 years ago #
  10. @bernd: Glad you found it helpful! Hopefully we'll be able to see your work in the gallery thread soon.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.