• Hi,

    is there any plugin or “hack” to add a shortcode to the bottom of post content of all posts in a category?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @amalaia11,

    What are you exactly trying to achieve? What should the plugin/shortcode do ?

    Ideally, as far as I know shortcodes are added in the editor to achieve a specific functionality. Are you looking for a plugin that will automatically add this short code at the end of all posts in all categories?

    Thread Starter amalaia11

    (@amalaia11)

    I have a blog with many posts in category A. I use a plugin (kodex like plugin) which let’s users vote about posts. This plugin has settings to activate voting on shortcode or on all posts.

    At the moment I use it on “all posts” which is fine but now I want to add posts in another category without the vote button. I do it with custom css “.hide” for the posts which I don’t want that vote button but thats not the best practice…

    Ideally I want to use the plugin only with shortcodes, but I have a big number of posts which I would have to edit manually…

    Hello @amalaia11,

    You can try something like this
    “yourcategory” is the category term for which you want to display things

    add_filter('the_content','shortcode_generator');
    function shortcode_generator($content){
        global $post;
        if(has_category('yourcategory',$post)){
            $content.='[yourshortcode]';
           return $content;
        }
        else{
            return $content;
        }
    }

    Add this code in your theme’s functions.php.Hope this will solve your purpose.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add shortcode to all posts in one category’ is closed to new replies.