Trying to create a shortcode to display categories with a specific product tag

You need to pass your attributes in the shortcode as key-value pairs, and use them in php as an array as follows: [tagtagtag tag_id=246] function get_categories_with_product_in_tag( $atts ) { global $wpdb; return $wpdb->get_results( $wpdb->prepare( “SELECT categories.* FROM “. “{$wpdb->prefix}terms categories “. “INNER JOIN {$wpdb->prefix}term_taxonomy ctax ON (categories.term_id = ctax.term_id) “. “INNER JOIN {$wpdb->prefix}term_relationships crel ON … Read more

url not using query string no longer working

So I never found out why this broke in the first place, but I did find a solution that forces the proper url to work add_action( ‘init’, ‘add_mypage_rule’ ); function add_mypage_rule(){ add_rewrite_rule(‘^item/([^/]*)/?’,’index.php?pagename=item’,’top’); } Sussed out from here: https://stackoverflow.com/questions/18713230/wordpress-url-rewriting-parameters-in-url

if get_post_meta is empty echo a placeholder or shortcode

You can use empty, to check your variable. Something like this $prod_id = get_the_ID(); if (!empty(get_post_meta($prod_id,’_product_tech’,true))) { echo'<a class=”shutter” title=”technische gegevens” href=”‘.get_post_meta($prod_id,’_product_tech’,true).'”><img width=”750″ height=”100%” src=”‘.get_post_meta($prod_id,’_product_tech’,true).'”></a>’; } else { //Is empty }