Your Time:
Our Time:
← Back to discussions

New Shortcode

Need help with a different issue? Search the forums or open a new ticket.
Open a support ticket

This topic has 3 replies, 2 voices, and was last updated 12 years, 9 months ago by Fem.

  • 2013-11-13 at 4:53 am
    Support Expired
    #688
    TheBandWagon
    Participant
    • Topics: 3
    • Replies: 5
    • Total posts: 8
    • Post count: 9

    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

    • This topic was modified 12 years, 9 months ago by TheBandWagon.
    2013-11-13 at 10:15 am
    #691
    Fem
    Keymaster
    • Topics: 2
    • Replies: 5215
    • Total posts: 5217
    • Post count: 6003

    Artists are not based on categories and it does not have categories fetching option, so we kept only genres for the artists. If you want we can add that feature to pull only genre based artists.

    I’m online in Skype if you need support

    2013-11-13 at 2:54 pm
    Support Expired
    #695
    TheBandWagon
    Participant
    • Topics: 3
    • Replies: 5
    • Total posts: 8
    • Post count: 9

    I have already successfully added a category to Artists called Upandcoming. Its just the shortcode I cant get to work.

    2013-11-14 at 12:11 pm
    #702
    Fem
    Keymaster
    • Topics: 2
    • Replies: 5215
    • Total posts: 5217
    • Post count: 6003

    Its fixed in your website.

You must be logged in to reply to this topic.