WordPress Shortcode loads at the top

First, declare your variable: $return = ”; Then, throughout the code, concatenate items: $return .= ‘<div class=”sp shadow”><img src=”https://wordpress.stackexchange.com/questions/81864/…”></div>’; $return .= ‘<h3>Videos</h3>’; And finally, return the result: return $return;

Is there a way I can return terms by name using a shortcode?

This is the solution to get post terms by taxonomy by shortcode: /** * Custom shortcode to get terms */ function ALC_post_terms_by_taxonomy( $atts ) { global $post; $taxonomyTerms = wp_get_post_terms( $post->ID, $atts[‘taxonomy’], ‘orderby=name&hide_empty=0’ ); $term_array = array(); foreach ($taxonomyTerms as $taxonomyTerm) { $term_array[] = $taxonomyTerm->name; } return implode( ‘, ‘, $term_array ); } add_shortcode(‘get_terms_by_taxonomy’, ‘ALC_post_terms_by_taxonomy’); … Read more

style css to header for shortcodes

You can insert any code in the header by hooking an action. header.php <?php wp_head(); ?> functions.php add_action( ‘wp_head’, ‘iulia_example’ ); function iulia_example() { echo ‘<style type=”text/css”> .sc_title {color:#fff; font-weight:600;} </style>’; } the result will be : the style inserted just above </head>

Add a short code to a plugin

Here is the code that you need to pull content from a wordpress page you will require the id number of the page and add it into the shortcode. [example page_id=”21″][/example] function example_shortcode( $atts, $content = null) { extract( shortcode_atts( array( ‘page_id’ => ” ), $atts ) ); // Will display our page content of … Read more

How to not show shortcode contents if cart is empty?

You can check the carts content then show the cart if it has some items // Add a WooCommerce Cart Total shortcode [cart_total] add_filter(‘woocommerce_add_to_cart_fragments’, ‘woocommerce_header_add_to_cart_fragment’); function woocommerce_header_add_to_cart_fragment( $fragments ) { global $woocommerce; ob_start(); ?> <a class=”cart-contents” href=”https://wordpress.stackexchange.com/questions/274073/<?php echo $woocommerce->cart->get_cart_url(); ?>” title=”<?php _e(‘View your shopping cart’, ‘woothemes’); ?>”><i class=”fa fa-shopping-cart “></i>&nbsp;<?php echo $woocommerce->cart->cart_contents_count;?></a> <?php $fragments[‘a.cart-contents’] = … Read more

If do_shortcode is blank, return some message

From several version of WordPress, it’s better to use https://developer.wordpress.org/reference/functions/apply_shortcodes/ io do_shortcode. That said you can surely do something using has_shortcode() https://developer.wordpress.org/reference/functions/has_shortcode/

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