Your Time:
Our Time:

New Shortcode

  • Resolved
    Posted in: MusicPlay  
    • Topics: 3
    • Replies: 5
    • Total posts: 8
    TheBandWagon
    Member
    November 13, 2013 at 4:53 am #688

    Hi,

    Im’ trying to create a shortcode that can be used in the shortcodes generator to display only UpandComing Artists on the homepage. I have setup a Up and coming category, and this is the code I have been using to create the shortcode:

    <?php
    function iva_upandcoming($atts, $content = null,$code) {
    extract(shortcode_atts(array(
    ‘cat’ => ‘3’,
    ‘limit’ => ‘-1’,
    ‘columns’ => ‘1’,
    ‘pagination’ => ”
    ), $atts));

    // $column_index = 0;
    // if( $columns == ‘4’ ) { $class = ‘col_fourth’; }
    // if( $columns == ‘3’ ) { $class = ‘col_third’; }

    //Album Image Sizes
    $width=’470′; $height = ‘470’;
    $out = ”;
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    $query = array(
    ‘post_type’ => ‘artists’,
    ‘showposts’ => $limit,
    ‘taxonomy’ => ‘genres’,
    ‘term’ => $cat,
    ‘paged’ => $paged
    );

    query_posts($query); //get the results
    global $post;
    if(have_posts()) : while(have_posts()) : the_post();
    $artist_bornplace = get_post_meta( $post->ID, ‘artist_bornplace’, true );
    $artist_genres = get_post_meta( $post->ID, ‘artist_genres’, true );
    $artist_year_active = get_post_meta( $post->ID, ‘artist_year_active’, true );
    $artist_website_url = get_post_meta( $post->ID, ‘artist_website_url’, true );
    //$artist_label = get_the_term_list( $post->ID, ‘label’, ”, ‘,’, ” );

    $column_index++;
    $last = ( $column_index == $columns && $columns != 1 ) ? ‘end ‘ : ”;

    $permalink = get_permalink( get_the_id() );
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’, true );

    $out .= ‘<div class=”artist-list ‘.$class.’ ‘. $last.'”>’;
    $out .= ‘<div class=”custompost_entry”>’;
    if(has_post_thumbnail()){
    $out .='<div class=”custompost_thumb port_img”>’;
    $out .='<figure>’;
    $out .= atp_resize( $post->ID, ”, $width, $height, ”, ” );
    $out .='</figure>’;
    $out .='<div class=”hover_type”>’;
    $out .=’‘;
    $out .='</div>’;
    $out .='</div>’;
    }
    $out .='<div class=”artist-desc”>’;
    $out .='<h2 class=”entry-title”>‘.get_the_title().’</h2>’;
    if ( $artist_genres != ” ) {
    $out .='<span>’.$artist_genres.'</span>’;
    }
    $out .= ‘</div>’;
    $out .= ‘</div>’;
    $out .= ‘</div>’;
    if( $column_index == $columns ){
    $column_index = 0;
    }
    endwhile;
    $out .='<div class=”clear”></div>’;
    if($pagination == ‘true’) {
    $out .=atp_pagination();
    }
    wp_reset_query();
    endif;
    return $out;
    }
    add_shortcode(‘upandcoming’,’iva_upandcoming’); //add shortcode
    ?>

    I’ve also added the following array to the shortcode-meta.php file:

    // UPANDCOMING
    //——————————————————–
    ‘UpandComing’ => array(
    ‘name’ => __(‘UpandComing’, ‘ATP_ADMIN_SITE’),
    ‘value’ => ‘artist’,
    ‘options’ => array(
    array(
    ‘name’ => __(‘Column’, ‘ATP_ADMIN_SITE’),
    ‘desc’ => ‘Select the Artist Columns Layout Style’,
    ‘id’ => ‘column’,
    ‘std’ => ‘4’,
    ‘options’ => array(
    ‘3’ => ‘Columns 3’,
    ‘4’ => ‘Columns 4’
    ),
    ‘type’ => ‘select’
    ),
    array(
    ‘name’ => __(‘Artist Limit’, ‘ATP_ADMIN_SITE’),
    ‘desc’ => ‘Type the number of items you wish to display per page’,
    ‘id’ => ‘limit’,
    ‘std’ => ‘4’,
    ‘type’ => ‘text’
    ),
    array(
    ‘name’ => __(‘Category’, ‘ATP_ADMIN_SITE’),
    ‘desc’ => ‘Hold Control/Command key to select multiple categories’,
    ‘info’ => ‘(optional)’,
    ‘id’ => ‘cat’,
    ‘std’ => ”,
    ‘options’ => $this->atp_variable(‘artist’),
    ‘type’ => ‘multiselect’
    ),
    array(
    ‘name’ => __(‘Pagination’, ‘ATP_ADMIN_SITE’),
    ‘desc’ => ‘Check this if you wish to disable the pagination.’,
    ‘id’ => ‘pagination’,
    ‘std’ => ”,
    ‘type’ => ‘checkbox’
    ),
    )
    ),

    The UpandComing shortcode shows up in the Shortcode Generator but the multiselect category field isnt showing, so I cant select the upandcoming artist category.

    Could you please guide me a little further with this development?

    Thankyou

    Regards

    Sorry, this forum is for verified users only. Please Login or Register to continue

Comments are closed.