Why does my JavaScript work in the browser console but does not work in my shortcode?

Solved by wrapping everything in document.addEventListener(“DOMContentLoaded”, function() {} Realized it was trying to fire the script off document.addEventListener(“DOMContentLoaded”, function () { var getSiblings = function (elem) { // Setup siblings array and get the parent var siblings = []; var sibling = elem.parentNode.parentNode; // Loop through each sibling and push to the array while (sibling) … Read more

Array to String Conversion warning in shortcode

You are getting that error because in the function parameter you are passing $content as 1st parameter but as per add_shortcode callback function it accepts 2 argument $atts – array $content – string It is basically trying to concat $atts param which is an array hence you are getting warning. Just update your code by … 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

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

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