We're merging with GenerateBlocks! Learn more here.

Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Combine Conditions Reply To: Combine Conditions

#18573
Philip
Participant

That approach could work, but I’d need to be able to set the class via the shortcode in the editor, and whenever I try to do that, I get a fatal error when I try to save, and then have to go remove that code from the database to fix it. This was my shortcode:

[wp_show_posts id="119" settings="wrapper_class=tag1-cat1"]

I kept playing with and found a clunky workaround, using a field that I’m not otherwise using:

[wp_show_posts id="119" settings="read_more_text=tag1-cat1"]

I’d have to then hide that Read More button with CSS, but its doable. I can then do this:

add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
    if ( 'tag1-cat1' === $settings['read_more_text'] ) {
        $args['category__and'] = 8;
        $args['tag__in'] = 68;
    } elseif ( 'tag1-cat2' === $settings['read_more_text'] ) {
        $args['category__and'] = 8;
        $args['tag__in'] = 25;
    } elseif ( 'tag2-cat1' === $settings['read_more_text'] ) {
        $args['category__and'] = 10;
        $args['tag__in'] = 28;
    }
    // etc.

    return $args;
}, 10, 2 );

Again, very clunky, but at least this gets me to a place where I don’t need to create dozens of Lists. Any better way you know of to do this now that you can see what I’m trying to accomplish?