Adding a css class to the gallery

If you look at the gallery shortcode you will see that you are using the wrong filter. With post_gallery you can override the complete html of the shortcode. Your code performs a str_replace on an empty string, resulting in an empty return and subsequently the generation of the default gallery html. Further on there is … Read more

Calling a function via a shortcode in javascript

I’m afraid the code you’ve shared is rather wonky and there isn’t just one thing that is backwards. Here are the first few things that came into my mind. add_filter( ‘learn-press/after-content-item-summary/lp_lesson’, ‘psb_comment_listener_func’); When you attach a callback function to a filter with add_filter, the callback should return a value. If the callback isn’t supposed to … Read more

php codes ruins shortcode structure

You need to change the_title() to get_the_title(). You are asking the shortcode to echo out a string that is returning the title. It would be good for you to research the difference between the_title and get_the_title. The main difference is that the_title is actually returning the title without any other requirement (this is simplified: there … Read more

get_the_ID() retrieves same ID on Gutenberg’s Query Loop

No, you did nothing wrong. It’s a known issue and in WordPress v6.1.3 and up to the current stable release as of writing (v6.2.2), it’s happening because of the following lines in get_the_block_template_html() which returns the markup for the current (block-based) template: $content = do_shortcode( $content ); $content = do_blocks( $content ); So as you … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)