Permalink Short code showing unnecessary link text inside the loop

ob_get_flush doesn’t do what you think it does. You’re assuming that it only ends the output buffer and returns its contents, which is incorrect, it also flushes the output buffer to the browser. So this: return ob_get_flush(); Is the same as this: $content = ob_get_clean(); echo $content; return $content; Use ob_get_clean(); instead, which erases the … Read more

How can I create a shortcode to show the number of posts of actual day?

I tried some codes, and I think finally works after several tries: function ts_day_f() { $posts= get_posts(array( ‘numberposts’ => -1, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘date_query’ => array( ‘column’ => ‘post_date’, ‘after’ => ‘today’, ‘before’ => ‘tomorrow – 1 second’, ) )); if ( is_user_logged_in()) { //return count($posts); $c = count($posts); … Read more

Get category slug of the Parent category of a Product

Put this below code in functions.php and Try it. add_action( ‘woocommerce_before_single_product’, ‘content_before_addtocart_button’ ); function content_before_addtocart_button() { global $post; $categories = array(); $taxonomies = get_terms( array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false, ‘parent’ => 0 )); if ( !empty($taxonomies) ) : foreach( $taxonomies as $taxonomy ) { $categories[] = $taxonomy->slug; } endif; $terms = get_the_terms( $post->ID, … Read more