shortcode with $atts with strange results

The functions you have above don’t use the id att at all. This might be what you want, but I’m not 100% sure what you’re going for. function show_homepage_banner_function($atts) { $atts = shortcode_atts( array(‘id’ => NULL), $atts ); $content=””; global $wpdb; $upload_url=””; $upload_dir = wp_upload_dir(); $target_dir = $upload_dir[‘basedir’]; $upload_url = $upload_dir[‘baseurl’].’/banners/’; $query = “SELECT * … Read more

excerpt in template for specific page

The following code will query the “blog” category for the latest three published posts and loop through these results to display the excerpt from each. $args = array( ‘category_name’ => ‘blog’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, ); $blog_posts = new WP_Query( $args ); if ( $blog_posts->have_posts() ): while ( $blog_posts->have_posts() ): $blog_posts->the_post(); // Do … Read more

Echo Category In Loop

The function get_theme_mod() returns information. Since you want to assign it and not echo it to the screen, we can remove the echo and PHP tags: $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 4, ‘product_cat’ => get_theme_mod( ‘vatname’, ‘Clothing’ ), ‘orderby’ =>’date’, ‘order’ => ‘ASC’ ); That should fix your query. … Read more

Create custom add to cart in WordPress

Use woocommerce_add_cart_item_data and woocommerce_add_order_item_meta filters. Wrap all your input fields inside product form( I assume that those tabs are made with javascript so there is no need of reloading the page for each one’s content) and set that form’s action to add to cart url Use this in your custom template $product = get_product(77); echo … Read more

echo statement repeats

I do not believe that the root issue exists within the code provided. I tested an even further reduced test case which I’ve pasted below, and I do not get duplicated content: function my_module_init() { add_filter(‘the_content’, ‘my_content_ctrlr’); } add_action(‘init’, ‘my_module_init’); function my_content_ctrlr( $content ) { ob_start(); // This file contains only the following simple text … Read more