does wp_insert_term link the term to a certain post ID?
Yes, wp_insert_term() only creates the term. To assign the term to a post use wp_set_object_terms() wp_set_object_terms( $object_id, $terms, $taxonomy, $append );
Yes, wp_insert_term() only creates the term. To assign the term to a post use wp_set_object_terms() wp_set_object_terms( $object_id, $terms, $taxonomy, $append );
Your problem is that you are defining the $typeName variable as an empty array at the stat of each iteration of the loop, effectively erasing it, then filling that empty array with a single term name, which you implode. You don’t see any commas because you are implodeing a one term array. Move the definition … Read more
The arguments for your query would be like: $args = array( ‘post_type’ => ‘articles’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘name’, ‘terms’ => ‘news’, ), ), ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); endwhile; endif;
From code for post type and custom taxonomy, your CPT is post_features and taxonomy is features. For single post_features, you need to have file named single-post_features.php. For archive, create file taxonomy-features.php. See documentation for detail. https://codex.wordpress.org/Post_Type_Templates Example for single(single-post_features.php): <?php get_header(); ?> <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); the_title(); … Read more
If you look at WordPress’ available query variables, you will notice post_type. You will need to add that to your URL: $terms = get_the_terms( $post->ID , ‘category’ ); foreach ( $terms as $term ) { $term_link = get_term_link( $term, ‘category’ ); if( is_wp_error( $term_link ) ) continue; $term_link = add_query_arg( array( ‘post_type’ => $post->post_type ), … Read more
It seems to me like this is just a regular addition to functions. Since you are asking, I think you may not be getting the result you are looking for. If this was my project, I would create a new plugin, install it into the regular plugin list so that it does not get overwritten … Read more
Please find the code its working you need to just add the js and css for your design it will add three custom post and add widget to the widget area you can drag and drop it in any side bar. <?php /** * Plugin Name: Custom Tabbed Plugin * Description: This is testing of … Read more
as ChrisL said in the comments, you should add order and orderby to your arguments : $args = array( ‘post_type’ => ‘totem’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ );
For example if there are 10 custom posts, and No. 1 is the oldest, and they happened to select the 3rd oldest one, they want it to say “No. 3”. There is a more elegant way than that function: $args = array( ‘post_type’ => ‘book’, ‘fields’ => ‘ids’, ‘ignore_sticky_posts’ => true, ‘orderby’ => ‘post_date’, ‘order’ … Read more
You shouldn’t use query_posts functions. You should create instance of WP_Query class In your theme folder create a new file called category-slug.php. You can copy the category.php file or archive.php file to create category-slug.php file. Then in the new category-slug.php file before the while loop you can write your query. $query = new WP_Query( ‘category_name=apple,pears’ … Read more