How can I create a shortcode that shows a list of categories on the single product page?

You can try this: function woo_prod_categories() { if ( is_product() ) { global $post; $product_cats = get_the_terms( $post->ID, ‘product_cat’ ); if ( ! empty( $product_cats ) && ! is_wp_error( $product_cats ) ) { $cat_links = array(); foreach ( $product_cats as $product_cat ) { $cat_links[] = ‘<a href=”‘ . get_term_link( $product_cat->term_id, ‘product_cat’ ) . ‘”>’ . … Read more

How to exclude some cats from wp_list_categories using shortcut

Exclude needs to be in the $cat_args, and in the shortcode_atts. Like this: extract( shortcode_atts( array( ‘exclude’ => ”, ‘categoriespostcount’ => ‘on’, ‘categorieshierarchy’ => ‘on’, ), $atts ) ); $cat_args = array( ‘exclude’ => $exclude, ‘taxonomy’ => ‘theme_portfolio_categories’, ‘show_count’ => $c, ‘hierarchical’ => $h, ‘echo’ => 0 );

How to use multiple values in “Shortcode”? [closed]

You can combine these two shortcodes into one by using a custom shortcode that includes both of them: function custom_shortcode() { $output=””; // Get the wpcode shortcode output $wpcode_output = do_shortcode(‘[wpcode id=”2658″]’); // Get the wpdiscuz_comments shortcode output $wpdiscuz_output = do_shortcode(‘[wpdiscuz_comments]’); // Combine the two outputs into a single output $output .= $wpcode_output . $wpdiscuz_output; … Read more

How to execute a shortcode within a custom field?

Using the_field(); will just return the content of that field (guessing it’s just text field?). <?php if (is_user_logged_in()) { $userid = get_current_user_id(); get_userdata($userid); $shortcode = get_field(‘view_files_shortcode’, ‘user_’ . $userid); } ?> <?php echo do_shortcode($shortcode); ?>