Categories
CMS Mastering Development Wordpress

SQL Query – custom tax_query not working when querying two taxonomies

I have a created a custom table in my WP database called wp_opportunities which stores locations with their lat and long. I’m trying to query the table based on the taxonomy term set on the post ID column found in the opportunities table. The taxonomies are called opportunity_type and opportunity_sector and I need it to […]

Categories
CMS Mastering Development Wordpress

How to insert 2 args into 1 Wp_Query for a slideshow

I need to post articles and pages present in two specific taxonomy in a slider. I tried to merge the $args and $args2 but the slider disappears from the page. Could anyone tell me how to write the code correctly? Thanks! This is the code: <?php $slider_counter = 0; $args = array( ‘post_type’ => ‘post’, […]

Categories
CMS Mastering Development Wordpress

Shortcode to show Media Attachments by Custom Taxonomy and Terms

I am trying to create shortcode that will list all attachments (in this case PDF documents) by custom taxonomy and term. Ideally I would like to be able to add multiple terms in an “and” or “or” fashion. I have the builtin Media tab with custom taxonomies such as “Media Industries” (taxonomy=media_industry) with terms such […]

Categories
CMS Mastering Development Wordpress

Shortcode for custom query not returning results when attributes are added

I’m trying to build a shortcode that will allow the user to choose what category is displayed and how many posts will show. The shortcode worked fine until I added the ‘tax_query’ add_shortcode( ‘latest_post’, ‘latest_post_query_shortcode’ ); function latest_post_query_shortcode( $atts ) { $atts = shortcode_atts( array( ‘post_per_page’ => ”, ‘category’ => ”, ), $atts ); $args […]

Categories
CMS Mastering Development Wordpress

Conditional Custom Post Type/Taxonomy on Tag Archive

I’m wanting to show ONLY the relevant posts for a specific tag. Example: Pet Friendly is a tag that applies to Restaurants, Hotels, and Parks (which are all location-type CPTs). I’ve figured out how to actually populate the posts but I can’t seem to figure out how to ONLY show Pet Friendly restaurants when you […]

Categories
CMS Mastering Development Wordpress

WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)

This is really confusing me. I’ve tried numerous things but cannot get appropriate results. Here’s what I currently have for my query: $args = array( ‘post_type’ => ‘product’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘ring’ ), ), array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ […]

Categories
CMS Mastering Development Wordpress

Orderby is working with one query but not with other

I’m using a shortcode to show some price boxes. I use a CPT with a custom field called ‘posicion’ which has a number that I use later to customize the loop. This is the code: <?php if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly // Add Shortcode function mostrar_tarifas_shortcode( $atts […]

Categories
CMS Mastering Development Wordpress

How do I combine two categories into one template?

This is the code I have, I’m trying to add the ‘used-boat-2’ category so all of the used boats appear with all of the new boats on a new page template. $the_query = new WP_Query( array( ‘post_type’ => ‘boat’, ‘posts_per_page’ => ‘-1’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘boat-categories’, ‘field’ => ‘slug’, ‘terms’ => ‘new-boat-2’ […]

Categories
CMS Mastering Development Wordpress

product_id is null when get data of product in functions.php

i create custom function to get all data of product to one category in functions.php function get_products() { $cat_id = $_POST[‘category’]; $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 1, ‘posts_per_page’ => ’12’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, //This is optional, as it defaults to ‘term_id’ ‘terms’ […]

Categories
CMS Mastering Development Wordpress

get all products of one category

i use this function to get all products of one category in ajax request function get_products() { $cat_id = $_POST[‘category’]; $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 1, ‘posts_per_page’ => ’12’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, //This is optional, as it defaults to ‘term_id’ ‘terms’ => […]