Tag Info

New answers tagged

0

The accepted answer for this question is unacceptable. It is illogical to assume that ordering by tax "doesn't make sense". The answer he gave doesn't make sense. Consider having a menu post type. Then you have a custom tax of "FoodCategories". The FoodCategories tax has "Breakfast", "Lunch" and "Dinner" terms. If you submit a query utilizing the ...


0

This question has the same solution as that one. The answer is short, so I post it here as well: In WordPress 3.9 (and still in 3.9.1) there's a bug concerning the excluded terms in get_adjacent_post(). There's a plugin to fix that bug.


0

You've been bit by a common gremlin: wp_list_categories doesn't take post_type as an argument. wp_list_categories always generates links to categories for the default post_type 'post.' If you want to use categories separated by custom post types, you need to specify the relevant permalink. Here's an approach to adding a permalink structure for custom post ...


0

You could use the posts_clauses filter: function wpse155797_posts_clauses( $pieces, $query ) { if ( ! is_admin() || ! $query->is_main_query() ) { return $pieces; } global $wpdb; if ( ( $orderby = $query->get( 'orderby' ) ) == 'asset_type' ) { if ( ( $order = strtoupper( $query->get( 'order' ) ) ) != 'DESC' ) $order = ...


0

Building on @jorghe's answer, you still need to get the the 'term_id'. This works but seems less than ideal: <?php $images = get_option('taxonomy_image_plugin'); $terms = get_the_terms($post->ID, 'byline'); foreach ( $terms as $term ) { $img_url = wp_get_attachment_url( $images[$term->term_id] ); print $img_url; } ...


2

It goes to the page, but I can't figure out how to modify my loop so it only shows posts that match the current term, in this example "element", nor display the title of the page as "Element". The following arguments for your loop should do: $args = array( 'post_type' => 'design_asset', 'posts_per_page' => 100, 'orderby' => ...


1

Steve, you've asked a couple of questions which I had a look at, and I came to the conclusion that your loop is causing all of your headaches. My loop to display ALL the posts is: $args = array( 'post_type' => 'design_asset', 'posts_per_page' => 100, 'orderby' => 'title', 'order' => 'ASC' ); $loop = new WP_Query( $args ); while ( ...


0

As written here, you need to use two nested arrays in the tax_query argument. So, with your arguments it should look like this: $args = array ( 'post_type' => 'restaurants', 'tax_query' => array (array( 'taxonomy' => 'location', 'field' => 'slug', 'terms' => 'citya') ), 'order_by' => 'title', 'order' => 'ASC' ); If you only need to ...


0

I think the easiest way would be like this: Custom Taxonomy Issue Custom Post Type Article You can add custom fields to Taxonomies like described here: https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/ This way, you get the relation between articles and issues, you can add information about the issue by the custom taxonomy fields, and ...


1

Add the following to your theme's functions.php: /** * Tests if any of a post's assigned categories are descendants of target categories * * @param int|array $cats The target categories. Integer ID or array of integer IDs * @param int|object $_post The post. Omit to test the current post in the Loop or main query * @return bool True if at least 1 of ...


0

You can try modifying your query using pre_get_posts filter. function mod_query() { if ($query->is_main_query() && !is_admin() && is_search()) { // test print queried search terms print_r( $query->query_vars['s'] ); $search_terms = $query->query_vars['s']; $search_terms = preg_replace('/\s+/', '+', ...


0

The best way is to use Advanced Custom Field plugin. It takes away all the hassle to create the fields, and update them. Procedure could be: 1. Install "Advanced Custom Fields" plugin 2. Create a new field-group 3. Add desired type of field(s) 4. Add this field group to category Now, you can see your added field(s) on the "Add New Category" or "Edit ...


0

Update... I have gotten the following to work well :) <?php $terms = get_terms( 'industrygroups' ); echo '<div class="row">'; foreach ( $terms as $term ) { // The $term is an object, so we don't need to specify the $taxonomy. $term_link = get_term_link( $term ); // If there was an error, continue to the next term. if ( ...


0

To retrieve all the terms in a taxonomy, you can make use of get_terms Here is an example from that page to retrieve the term names of a custom taxonomy $terms = get_terms('my_taxonomy', 'hide_empty=0'); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ echo "<ul>"; foreach ( $terms as $term ) { echo "<li>" . ...


0

It's hard to know what aspect of this you are asking for help with, but as a developer I would create it like this: Create a page for each image gallery, perhaps using WordPress's built in gallery feature Set a featured image on each gallery page Create a set of relationship fields in Advanced Custom Fields, perhaps with the paid Repeater add on, to let ...


0

I think your best bet would be to setup categories / sub categories. Example: News Counter-Strike StartCraft2 and link them together that way. This will (I believe) especially be much easier when querying your posts, so that you can query from a specific category (ie: Counter-Strike News)


0

First off, you should be using WP_Query vs query_posts. Have a look at the Taxonomy Parameters. Mainly tax_query and relation. // Repost from link above $args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'movie_genre', ...


0

You'll want to have a look at get_the_terms(). <?php // You need to define the post id from the post you are outputting in the right bar so that the left bar knows how to match up the terms $country = get_the_terms( $post->id, 'countries' ) $args = array( 'post_type' => 'side_menu', 'posts_per_page'=> 1, 'tax_query' ...


0

I suggest that you use a shortcode to display taxonomy of your choice : create a class to declare the shortcode and call this function public function shortcode($atts) { extract(shortcode_atts( array( 'data' => 'taxonomy', 'taxonomy' => 'category', //get_terms arguments 'parent' => 0, //only get top level terms by default ...


0

You have double posted this question, and in your comment in the previous question you said that you don't know if you are using build-in categories or custom taxonomies. Essentially, built-in categories and custom taxonomies are both Taxonomies, and the "categories" that you create in the back end are in actual fact just terms of the taxonomy 'category', ...


1

The code has some bugs as provided above. Use the following code to also make in working in the quick edit modus: How to hook into the quick edit action? (provided by Pieter Goosen) add_action('save_post', 'assign_parent_terms'); function assign_parent_terms($post_id){ global $post; if(isset($post) && $post->post_type != 'event_type') return ...


0

Using strip_tags() gets complicated if you want to show your terms as an HTML list. Here, there's something for you. $raw set to true (or anything that's not empty) will just create an inline list with the $separator of your choice, if not, it will generate an HTML list without links. If you want your list to have a styled title, set the $titletag to, say H1 ...


0

Ok, so I think I've got something for you! As you know, I've had the same issue, and when I was looping through each taxonomy I found that I was generating between 25-35 queries, which is crazy! So I decided to have a go at some MySQL on the term relationships table to see if there was a faster was to query the data. With some help from a great developer I ...


0

You can use the query below for this issue. // WP_Query arguments $args = array ( 'post_type' => 'my_custom_post_type', 'slug' => 'citation/auteur', 'post_status' => 'publish', 'author_name' => 'author_name', 'order' => 'DESC', ); // The Query $my_query = new WP_Query( ...



Top 50 recent answers are included