Grow your CSS skills. Land your dream job.

How display posts from category and tag using shortcode in Wordprss

  • # March 28, 2013 at 12:40 am

    I tried with this code, but this is not perfect.

    I want it like that [artist category=video&&tag=8]

    But below the code working only for tag id 7, for working shortcode like this, how i change in on the code

    I tried with this code, but this is not perfect.

    I want it like that [artist category=video&&tag=8]

    But below the code working only for tag id 7, for working shortcode like this, how i change in on the code

    # March 28, 2013 at 12:44 am


    function recent_posts_function($atts) {
    extract(shortcode_atts(array(
    "category" => 'video',
    "tag" => '7',

    ), $atts));

    $args = 'my_video';
    $args = $category;
    $args = 12;

    $args = false;
    $args=$tag;
    // query_posts($args);
    $query = new WP_Query( $args );
    $counter = 0;


    ?>



    < ?php
    $counter = 0;

    if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
    $query->the_post(); $counter++;
    ?>




    < ?php
    $args = 'key=image&width=' . $my_options . '&height=' . $my_options . '&class=thumbnail&link=img&return=true&id=' . get_the_ID();

    echo ' 0 ) ) . '">' . my_image_vimeo( $args ) . '';
    ?>


    " rel="bookmark" title="< ?php the_title(); ?>">< ?php the_title(); ?>








    < ?php if($counter % 4 == 0) { ?>

    < ?php } ?>

    < ?php
    } // End WHILE Loop
    echo '
    ';
    //my_pagination();
    wp_reset_postdata();
    remove_filter( 'pre_get_posts', 'my_filter_homepage_videos_query' );
    } else {
    ?>


    < ?php _e('Sorry, no posts matched your criteria.', 'mythemes'); ?>




    < ?php } // End IF Statement ?>





    < ?php
    wp_reset_query();
    return $return_string;
    }
    function register_shortcodes(){
    add_shortcode('artist', 'recent_posts_function');
    }
    add_action( 'init', 'register_shortcodes');
    add_filter('widget_text', 'do_shortcode');

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".