New answers tagged

0

You can use a multidimensional array to get this format. Please see the example given below: $terms = get_terms( array( 'taxonomy' => "issueCompanion", 'hide_empty' => false, 'fields'=>'all' ) ) $multi_arr = array(); foreach($terms as $term){ $year = get_field('published_year', $term->term_id); $...


0

// set Selected Post CATEGORY cheked wp_set_object_terms( $post_id, array((int)$_POST['movies_cat']), 'movies' ); } else{ die("check seccurity");} // This bellow given code add on design page <p class="meta-options hcf_field"> <label for="movies">The Categories</label> <?php wp_dropdown_categories( 'taxonomy=...


0

Inside of your loop on the taxonomy-issueCompanion.php template file you can retrieve the terms of the taxonomy that are attached to the post. // Inside of your while loop $post_topics = get_the_terms($post->ID, 'topic'); // And then you can do as you wish with your topics!


0

has_term() need third parameter to specify which post type have this term. So, your code would be if ( has_term('sold', 'category', 'property')) { ?> <div class="sold_prop_note"> <h3>This Property is sold. Take a look at our current exclusives! <a href="/properties">View Exclusives</a></h3> </div> <?php }...


-1

You need to update below line at where you have register a custom post type using register_post_type function. 'rewrite' => array('slug' => 'movies/%cat%') To change permalink dynamically of post type you have to add below code in functions.php file : function change_link( $post_link, $id = 0 ) { $post = get_post( $id ); if( $post->post_type == ...


0

The problem is that category_name is a reserved keyword for the built-in categories for posts. Almost anything category_* is reserved. You can find a list of reserved keywords at the following url: https://codex.wordpress.org/Reserved_Terms This includes, but is not limited to: cat category category__and category__in category__not_in category_name term ...


1

This question is a follow up of this question you asked earlier. Here we handled getting count per posttype. So you have all data, just not sorted correctly. Looking at your code you have one big problem. Getting and formatting data is done at the same time as you are outputting the data. For maintainability (and readability) it is best to separate these as ...


0

I was able to fix it by using this function add_action( 'series_add_form_fields', 'sermon_series_add_details', 10, 2 ); instead of this: add_action('add_meta_boxes','add_Book_series_metabox');


0

Here, i have develop a simple demo for get a post data of depends on category without loading page using Ajax and jQuery. Here is a main category, sub category and post dropdowns : $args = array( 'orderby' => 'name', 'hierarchical' => 1, 'taxonomy' => 'category', 'hide_empty' => 1, 'parent' => 0, ...


0

A better approach would be to save two meta fields. One for the candidateID and one for the recruiter. Then when you need to query the posts you should use the WP_Meta_Query with both meta fields and the relation argument set to 'AND': $args = array( 'post_type' => 'opening', 'meta_query' => array( 'relation' => 'AND', array( '...


1

You can set orderby slug like : $tags = get_tags( 'order=ASC&orderby=slug' ); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>"; $html .= "{$tag->name}</a>"; } $html .= '</...


0

It is possible to register a taxonomy without associating a post type by passing null as your argument for the $object_type. Unfortunately, this means that you will still need to associate an object type (post type) to your taxonomy later in order to use it. register_taxonomy( 'aprwc_rating_criteria', null, $args ); From the documentation: Setting ...


1

You have all sorts of fun questions today! There is also a WP_Term_Query available in WordPress. Here is some info on it as well as what parameters you can pass it. https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/ $term_args = array( 'taxonomy' => array('tax_one', 'tax_two', 'tax_six'), 'hide_empty' => false, 'fields' ...


1

When importing you could create a taxonomy for each unique stance key, then add the value as a term to the taxonomy for that key, then assign that term to the post. I'd suggest something like: Store the stance keys somewhere in the database (probably as options), making sure that you don't have duplicates. Depending on how many you have, this could ...


0

You need to update below line at where you have register a custom post type using register_post_type function. 'rewrite' => array('slug' => 'courses/%cat%') To change permalink dynamically of post type you have to add below code in functions.php file : function change_link( $post_link, $id = 0 ) { $post = get_post( $id ); if( $post->post_type ==...


-1

You need to update below line at where you have register a custom post type using register_post_type function. 'rewrite' => array('slug' => 'teachers/%cat%') To change permalink dynamically of post type you have to add below code in functions.php file : function change_link( $post_link, $id = 0 ) { $post = get_post( $id ); if ( is_object( $...


0

Here is the solution I ended up with. This may help others too. $taxonomy = "product-category"; $args = array( 'taxonomy' => $taxonomy, 'orderby' => 'name', 'order' => 'ASC', 'hierarchical' => true, 'hide_empty' => false, ); $the_query = new WP_Term_Query($args); $categories = $...


0

In your cases "wp_insert_term" does not save extra custom fields. Please try with below code : foreach ( $this->terms as $term_key=>$term) { // insert new terms in taxonomy wp_insert_term( $term['name'], $this->taxonomy, array( 'slug' => $term['slug'], 'description' => $term['...


-1

Okay so the solution was just adding this code to the $args 'has_archive' => 'companies',


0

With the new WordPress admin area "show_in_rest" must be set to true for custom taxonomies to show up in page editor.


1

You can create taxonomy-cat-cpt.php, and inside it just use: <?php get_template_part( 'archive-cpt' ); ?> Then they'll both use the same template. Then inside archive-cpt.php, if you use the_archive_title() archive the_archive_description() it will display the appropriate title and description automatically based on whether you're viewing the ...


2

Your 3rd option is correct. $args3 = array( 'posts_per_page' => 9, 'orderby' => 'date', 'order' => 'DESC', // If you're only specifying one. Use array( 'projects', 'post' ); for many. 'post_type' => 'projects', // This is the correct syntax for a taxonomy query. 'tax_query' => array( ...


0

That would be achieved using the wp_set_post_terms function. https://codex.wordpress.org/Function_Reference/wp_set_post_terms You could run an ajax request on the change event of the dropdown to either wp-admin/admin-ajax.php or a custom JSON API endpoint (preferred but more work) with a payload like this { new_status: 123 post_id: 321 } Ensure ...


0

You can use 'type' => 'DECIMAL(10, 2)', in meta query. It is mentioned in the documentation Custom_Field_Parameters.


0

Solution: Shadow Taxonomy Lib https://github.com/mrbobbybryant/shadow-taxonomy This looks like a robust solution for this issue and including wp cli support for creating, deleting, and evaluating the linkages. I haven't test it yet but it seems like the perfect solution for this issue.


0

There is some missing parts in your code: Try the following: add_action('restrict_manage_posts', 'admin_products_by_manufacturer_filter_dropdown'); function admin_products_by_manufacturer_filter_dropdown() { global $typenow, $pagenow; $taxonomy = 'vyrobca'; // The custom taxonomy if( 'edit.php' === $pagenow && 'product' === $typenow &...


0

The way you are customizing the query you are telling it to search for posts that ALSO match a custom tax_query criteria. This would never work, logically speaking. You said, "I want it to return a result if this tag is searched or if it matches the title" for which I understand ONE or ANOTHER. I'll show you a completely different approach, using basically ...


0

I think you need to remove $_GET['post_type'] Please use below code i think you might help : add_action( 'pre_get_posts', function ( $q ) { if ( !is_admin() // Only target front end, && $q->is_main_query() // Only target the main query && $q->is_search() // Only target the search page ) { ...


Top 50 recent answers are included