• I want to add a read more link automatically in a certain category. I added the following to function.php, but no go

    add_filter('the_content', 'custom_category_text');
    
    function custom_category_text($content){
        global $post;
        $custom_category_text = '<!--more-->';
        if(in_category('3')){
            $content = substr($content, 0, 300) . $custom_category_text . substr($content, 300);
        }
        return $content;
    }
Viewing 1 replies (of 1 total)
  • why dont you just make a template file for the category itself??

    just copy your curent index.php (if that’s all you’re using so far) and call it category-3.php, then put the read more link and substr there while every other part of the site stays different

    EDIT: whoops misread, just put the if in category as part of your single.php?

Viewing 1 replies (of 1 total)
  • The topic ‘add content to a specific category post’ is closed to new replies.