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

wordpress shortcode url decode non Latin character

It makes sense to look at the PHP function rawurldecode, which decodes URL-encoded strings. https://www.php.net/manual/en/function.rawurldecode.php For example, echo rawurldecode(get_permalink($post->ID)); will show the decoded post URL. But this isn’t really needed in hyperlink code. Sorry I didn’t just write a comment, I don’t have enough points for that option.

conditional shortcodes

Thank you, @Howdy_McGee! current_filter() is exactly what I’ve been looking for. Here is what I did: function french_example( $atts , $content = null ) { $currentFilter = current_filter(); if ($currentFilter == the_content) { return ‘<span class=”ex” xml:lang=”fr” lang=”fr”>’ . do_shortcode($content) . ‘</span>’; } elseif ($currentFilter == the_title) { return ‘<span class=”ex” xml:lang=”fr” lang=”fr”>’ . do_shortcode($content) … Read more