Skip to main content
deleted 61 characters in body
Source Link

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode');

function speakers_overview_shortcode($atts){

    $args = array(
        'post_type' => 'qp_speakers',
        'post_status'           => 'publish',
        'orderby'               => 'menu_order',
        'order'                 => 'ASC',
        'posts_per_page'        => -1,
        'meta_query' => array(
            array(
                'key' => 'speakers_jaar',
                'value' => '2017',
            )
        )
    );

    return str_repeat( ' ', (int) $args['value'] );

    ob_start();

    $locaties = new WP_Query( $args );

    if ( $locaties->have_posts() ) : ?>
        <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
            <?php q2_speakers_template(); ?>
        <?php endwhile; // end of the loop. ?>
    <?php endif;
    
    wp_reset_postdata();
    
    return ob_get_clean();
}

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode');

function speakers_overview_shortcode($atts){

    $args = array(
        'post_type' => 'qp_speakers',
        'post_status'           => 'publish',
        'orderby'               => 'menu_order',
        'order'                 => 'ASC',
        'posts_per_page'        => -1,
        'meta_query' => array(
            array(
                'key' => 'speakers_jaar',
                'value' => '2017',
            )
        )
    );

    return str_repeat( ' ', (int) $args['value'] );

    ob_start();

    $locaties = new WP_Query( $args );

    if ( $locaties->have_posts() ) : ?>
        <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
            <?php q2_speakers_template(); ?>
        <?php endwhile; // end of the loop. ?>
    <?php endif;
    
    wp_reset_postdata();
    
    return ob_get_clean();
}

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode');

function speakers_overview_shortcode($atts){

    $args = array(
        'post_type' => 'qp_speakers',
        'post_status'           => 'publish',
        'orderby'               => 'menu_order',
        'order'                 => 'ASC',
        'posts_per_page'        => -1,
        'meta_query' => array(
            array(
                'key' => 'speakers_jaar',
                'value' => '2017',
            )
        )
    );

    ob_start();

    $locaties = new WP_Query( $args );

    if ( $locaties->have_posts() ) : ?>
        <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
            <?php q2_speakers_template(); ?>
        <?php endwhile; // end of the loop. ?>
    <?php endif;
    
    wp_reset_postdata();
    
    return ob_get_clean();
}
added 134 characters in body
Source Link
mmm
  • 3.8k
  • 3
  • 16
  • 22

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode'); function speakers_overview_shortcode($atts){

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode');

function speakers_overview_shortcode($atts){

    $args = array(
        'post_type' => 'qp_speakers',
        'post_status'           => 'publish',
        'orderby'               => 'menu_order',
        'order'                 => 'ASC',
        'posts_per_page'        => -1,
        'meta_query' => array(
            array(
                'key' => 'speakers_jaar',
                'value' => '2017',
            )
        )
    );

    return str_repeat( ' ', (int) $args['value'] );

    ob_start();

    $locaties = new WP_Query( $args );

    if ( $locaties->have_posts() ) : ?>
        <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
            <?php q2_speakers_template(); ?>
        <?php endwhile; // end of the loop. ?>
    <?php endif;
    
    wp_reset_postdata();
    
    return ob_get_clean();
}

}

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode'); function speakers_overview_shortcode($atts){

$args = array(
    'post_type' => 'qp_speakers',
    'post_status'           => 'publish',
    'orderby'               => 'menu_order',
    'order'                 => 'ASC',
    'posts_per_page'        => -1,
    'meta_query' => array(
        array(
            'key' => 'speakers_jaar',
            'value' => '2017',
        )
    )
);

return str_repeat( ' ', (int) $args['value'] );

ob_start();

$locaties = new WP_Query( $args );

if ( $locaties->have_posts() ) : ?>
    <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
        <?php q2_speakers_template(); ?>
    <?php endwhile; // end of the loop. ?>
<?php endif;

wp_reset_postdata();

return ob_get_clean();

}

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode');

function speakers_overview_shortcode($atts){

    $args = array(
        'post_type' => 'qp_speakers',
        'post_status'           => 'publish',
        'orderby'               => 'menu_order',
        'order'                 => 'ASC',
        'posts_per_page'        => -1,
        'meta_query' => array(
            array(
                'key' => 'speakers_jaar',
                'value' => '2017',
            )
        )
    );

    return str_repeat( ' ', (int) $args['value'] );

    ob_start();

    $locaties = new WP_Query( $args );

    if ( $locaties->have_posts() ) : ?>
        <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
            <?php q2_speakers_template(); ?>
        <?php endwhile; // end of the loop. ?>
    <?php endif;
    
    wp_reset_postdata();
    
    return ob_get_clean();
}
Source Link

Filter content in shortcode

So, im kinda new to this shortcode but i've almost got working what i need now. (check below of the code)

I would like to filter my content within my shortcode, i'm having a CPT with fields added by the ACF plugin. Now what i need is when i place [speaker_overview_2017 year=2017] it shows only the items with value 2017, and when i'm doing [speaker_overview_2017 year=2018] only 2018, and when i'm doing [speaker_overview_2017] it show's all the items.

Here is my shortcode code, could someone help me out with this?

add_shortcode('speaker_overview_2017', 'speakers_overview_shortcode'); function speakers_overview_shortcode($atts){

$args = array(
    'post_type' => 'qp_speakers',
    'post_status'           => 'publish',
    'orderby'               => 'menu_order',
    'order'                 => 'ASC',
    'posts_per_page'        => -1,
    'meta_query' => array(
        array(
            'key' => 'speakers_jaar',
            'value' => '2017',
        )
    )
);

return str_repeat( ' ', (int) $args['value'] );

ob_start();

$locaties = new WP_Query( $args );

if ( $locaties->have_posts() ) : ?>
    <?php while ( $locaties->have_posts() ) : $locaties->the_post(); ?>
        <?php q2_speakers_template(); ?>
    <?php endwhile; // end of the loop. ?>
<?php endif;

wp_reset_postdata();

return ob_get_clean();

}