I'm creating a music database site with two custom post types: tracks and albums. I've linked the tracks to their respective albums with a custom taxonomy for the album's slug. On each album page, I'm trying to get a tracklist of the album by retrieving all tracks with a dub_album_slug taxonomy that matches the slug of the current album. Here's my code for that query: global $post; $post_slug = $post->post_name; $args = array ( 'post_type' => 'dub_track', 'tax_query' => array( …
In the recent wordpress.org article outlining the new Query Loop block, it says the "Inherit query from template" option allows you to "customize the query that the loop relies upon ... WordPress will otherwise rely on the template being used to determine what posts appear". There appears to be no further guidance on this. What does this mean, and where does it find a query for these posts? If I have a custom taxonomy defined, how would I pull from …
I have a custom post type Wine, which has an ACF Field that links to another custom post type Producer as a post_object relation. In my Producer, I have a custom taxonomy named Region. Now, what I'm trying to do is to query all the white wines where the producer's region is x. Here's what I've tried: $args = array( 'post_type' => 'wines', 'posts_per_page' => 12, 'tax_query' => array( array( 'taxonomy' => 'type', 'field' => 'slug', 'terms' => 'white' ), …
I have a custom post type, called prognosis with 3 custom taxonomies, Country, Competition, and Sport, I've also added a few ACF custom fields. I have another custom post type called analysis with an ACF relationship field prognosis connected to the prognosis custom post type. I want to be able to display certain taxonomy/ies the custom post type prognosis is connected to, through the relationship field that I have selected in the analysis custom post type. I tried debugging the …
My blog posts have have multiple items from my custom taxonomy attached to them. For the sake of this post lets just use Tags taxonomy... So a post may contain 4 tags, is there a way I can select one tag as the primary tag for the post?
I have a lot of custom taxonomies for my WordPress site. What I want to do is to Get Related Custom Taxonomies based on a Category. Sample Structure: (Material, OS and Features are Custom Taxonomies.) Post Category (CT)Material (CT)OS (CT)Features P1 A iOS OLED P2 B Metal GPS P3 C Glass Anroid GPS So what I want: For Category A: its related taxonomies is OS and Features. For Category B: its related taxonomies is Material and Features. For Category C: …
I'm attempting to display a specific taxonomy (channel) in the archive.php page. I want to display the taxonomy's URL, name, post count, and taxonomy image. This is what I have that's working so far: <?php $taxonomy = 'channel'; $tax_terms = get_terms($taxonomy); $image_url = print apply_filters( 'taxonomy-images-queried-term-image', '' ); ?> <ul> <?php foreach ($tax_terms as $tax_term) { ?> <li> <?php echo esc_attr(get_term_link($tax_term, $taxonomy)); ?> <?php echo $tax_term->name; ?> <?php echo $tax_term->count; ?> <?php echo $image_url->image_id; ?> </li> <?php } ?> </ul> …
I added some custom field and taxonomy in post /page/product main like Type, Channels, Battery etc.I created with custom post type UI plugin & ACF plugin but it is not showing in frontend of post page or product page. How do i show it ?
I have different taxonomies, let's say category and colour, these 2 tax have different terms, the tax are in parallel, a product can be in the category A and have colours X, in my frontend when I go in the page for the category A I show all the products in the category A, in this page I also show all the colours as filter, I'd like to hide all the colour that are not present in any product in …
I am trying to display the post count of some taxonomies. I have a custom template that I am showing some taxonomies on. I am using advanced custom fields to assign each repeater field to a taxonomy. How can I display the amount of post for each one?
I'm attempting to display a list of all posts from multiple categories (if anyone answers this, you might want to include combining tags as well, as probably that will make this answer comprehensive for future seekers). Here's what I'm working with: This function works to show a list: function my_custom_loop_three_posts($category, $tag, $offset) { $args=array( // showposts has been replaced, use 'posts_per_page' instead // 'showposts' => 1, 'posts_per_page' => 3, // this has been replaced, use 'ignore_sticky_posts' // 'caller_get_posts' => 1, …
I am trying to use wp_list_pluck to return an array of taxonomy names from get_terms. I'm not sure what I'm doing wrong, but this only echo's out "Array": $terms = get_terms(array( 'taxonomy' => 'state', 'hide_empty' => false, )); $term_ids = wp_list_pluck( $terms, 'name' ); echo $term_ids; Do you know how I can echo out an array of taxonomy names? The reason I am doing this is because I am wanting to get an array to convert it to a Javascript …
I'm working on tweaking a template which has a filterable masonry layout. I made a taxonomy-categories.php and for the filtering I need the terms of the active taxonomy. The template which I'm using has this code inside it <ul id="filter"> <li><a href="#" class="current" data-filter="*" title="">*</a></li> <?php $categories = get_terms('categories'); foreach( (array)$categories as $categorie){ $cat_name = $categorie->name; $cat_slug = $categorie->slug; ?> <li><a href="#" data-filter=".<?php echo esc_attr($cat_slug); ?>"><?php echo esc_attr($cat_name); ?></a></li> <?php } ?> </ul> As you can see it takes all …
I have a custom taxonomy (projects) linked to several different custom post types (events, stories, tutorials, news, podcast), as well as pages. [I KNOW, but that is how I need it to be] And have bashed the permalinks so that we can have: example.com/project-1-name/events/ example.com/project-2-name/events/event-details-page/ example.com/project-1-name/news/ example.com/project-2-name/contact-us-page/ etc etc etc... All working great... apart from one thing. when we enter example.com/project-1-name/ - I don't want each project's taxonomy term root archive to show, I want the 'home' page for each …
I try to output a list of terms from my custom taxonomy. I am almost sure I was using this code snippet before, but somehow WP throws errors: shuffle() expects parameter 1 to be array array_slice() expects parameter 1 to be array usort() expects parameter 1 to be array, null given /* Show Custom Taxonomy Terms */ function these_rand_tax1() { $max = 8; //number of categories to display $taxonomy = 'baumaschinen_cat'; $terms = get_terms('taxonomy='.$taxonomy.'&orderby=name&order=ASC&hide_empty=0'); // Random order shuffle($terms); // Get …
I am working with a custom category taxonomy field named ‘category-tax’ in WordPress using Advanced Custom Fields. I am trying to have the main parent category be a button for all parent and child related posts. Having a challenging time figuring out how to get the parent category returned, when the parent category is designated in the post. It seems I am only getting the parent category returned when the child category is designated. I am working with what appears …
I have two seperate Taxonomy Categories that I have attached to a post type. I'm trying to run a query to display the results in a nested manner. I can't seem to figure out a way to make it work once I introduce the second category. Any help would be appreciated. Category 1 Apples Grapes Category 2 Breakfast Lunch Dinner OUTPUT: Apples Breakfast Posts Here Lunch Posts Here Dinner Posts Here Grapes Breakfast Posts Here Lunch Posts Here Dinner Posts …
<?php $fields = acf_get_fields('6066'); ?> <?php if( $fields ) { foreach( $fields as $field) { $value = get_field( $field['name'] ); if ($value) { echo '<dl>'; echo '<dt>' . $field['label'] . '</dt>'; echo '<dd>' . $field['value'] . '</dd>'; echo '</dl>'; } } } ?> This is what I have. If I do a var_dump on acf_get_fields, it apparently sets the value to NULL. I could have known, as it's written here: https://www.advancedcustomfields.com/resources/get_field_object/ The problem: I have to first get all fields …
For a site I need to show related posts for a custom taxonomy. Because another person build this site and also created a custom taxonomy, and this code can't be found in a proper file like functions.php or a plugin, I need to track this name so I can use it for other code solutions. For clarity; If I create a custom taxonomy, a part of the code is register_taxonomy('**SUBJECT TO TRACK**',array('customposttype'), array( I need to track the part of …
I have custom post type A, and B. B has a relationship back to A via an ACF Post Object field. A has (custom) taxonomies that B does not. How do you get all B where A is in taxonomy X. I imagine how you would do this with SQL using an inner join, but wanted to see if its possible using a single WP_Query? I've only found examples where you are querying based on the related site id (https://www.advancedcustomfields.com/resources/querying-relationship-fields/). …