WordPress Custom Post Type and Shortcode for Portfolio Items

I used this code to display and make shortcode of custom post type.
its worked, i wnat to remove the anchor tag on this , when i remove anchor tag its shows error hoe can i fix this ?
here code :

adminmenu .menu-icon-portfolio div.wp-menu-image:before {

content: “f322”;

}

_x(‘Portfolio’, ‘post type general name’),
‘singular_name’ => _x(‘Portfolio Item’, ‘post type singular name’),
‘add_new’ => _x(‘Add New’, ‘Portfolio Item’),
‘add_new_item’ => __(‘Add New Portfolio Item’),
‘edit_item’ => __(‘Edit Portfolio Item’),
‘new_item’ => __(‘New Portfolio Item’),
‘all_items’ => __(‘All Portfolio Items’),
‘view_item’ => __(‘View Portfolio Items’),
‘search_items’ => __(‘Search Portfolio Items’),
‘not_found’ => __(‘No portfolio items found’),
‘not_found_in_trash’ => __(‘No potfolio items found in Trash’),
‘parent_item_colon’ => ”,
‘menu_name’ => ‘Portfolio’
);
$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘query_var’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘has_archive’ => false,
‘hierarchical’ => false,
‘menu_position’ => 20,
‘supports’ => array( ‘title’, ‘editor’, ‘revisions’, ‘page-attributes’, ‘thumbnail’, ‘excerpt’ ),
‘menu_icon’ => ”,
);
register_post_type(‘portfolio’,$args);
}
// Add Shortcode
function portfolio_shortcode( $atts ) {

extract( shortcode_atts( array(
“name” => false,
), $atts ) );

global $cfs;
$ul_class = ‘list-portfolio’;
$ul_class .= ( $name ) ? ” : ‘ row’;

$li_class = ‘list-portfolio-item’;
$col_class = ( $name ) ? ” : ‘ col-sm-6’;

$lis = ”;
if($name) {
$query = new WP_Query( array(
‘post_type’ => ‘portfolio’,
‘name’ => $name,
‘order’ => ‘ASC’,
) );
} else {
$query = new WP_Query( array(
‘post_type’ => ‘portfolio’,
‘orderby’ => ‘menu_order’,
‘order’ => ‘ASC’,
) );
}
while ( $query->have_posts() ) : $query->the_post();
$lis .= sprintf(
‘ %s %s

%s

‘,
esc_attr( $col_class ),
esc_attr( $li_class ),
esc_url( get_permalink() ),
get_the_post_thumbnail( $post_id, ‘thumbnail’, array(‘class’ => ‘pull-left portfolio-thumb img-circle’) ),
get_the_title(),
get_the_excerpt()
);

endwhile;
wp_reset_query();
return sprintf(
‘%s’,
esc_attr( $ul_class ),
$lis
);
}
?>

Read more here:: WordPress Custom Post Type and Shortcode for Portfolio Items

Leave a Reply

Your email address will not be published. Required fields are marked *