same permalink for parent category and child category
This might be because you have created wordpress-plugins twice. Please check your database if it already exists.
This might be because you have created wordpress-plugins twice. Please check your database if it already exists.
I believe what you’re seeing is the expected behavior when parent is set to 0 which is what get_cat_id() returns if it fails to find a category ID for the $cat_name argument. You can quickly test this by putting var_dump($current_cat_id); anytime after you set it to see if this guess is right. If so, you’ll … Read more
Try going to your permalinks page within the admin to flush the rewrite rules. Just be navigating to that page will flush the rules, but you could click save even if you made no changes.
gdaniel, thank you for your reply, but actually I mean different : 1) show missing fields in my post_type listing 2) modify categories block, not to add/delete categories, but always show 2 existing categories, as they are constants for my post_type .
Since you’re not currently running a multi-site install, you can either install the WP-REST-API plugin which is currently in beta, or you can wait for it to hit core which will probably be around version 4.3 or 4.4. If you were on a multi-site install, you could have easily used the switch_to_blog() function to switch … Read more
Display posts that have “all” of these categories: $query = new WP_Query( ‘category_name=staff+news’ ); See this on category parameters.
First query all post $args = array( ‘post_type’ =>’posts’, ‘post_status’ =>’publish’, ‘posts_per_page’ =>-1 ); $query = new WP_Query($args); $post_ids = array(); if($query->have_posts()){ while ($query->have_posts()){ global $post; $query->the_post(); array_push($post_ids,$post->ID); } } Now you have an array called $post_ids which contains all post’s id . Now , change the categories Loop through the array and change the … Read more
Absolutely. Since you can instantiate to a variable a query you can do it as much times as you want. Of course query loops require a lot of connections to the database so you have to be careful. Very often if you need many subqueries it basically means that your workflow can be enhanced in … Read more
The simplest solution: echo get_the_category_list( ‘, ‘ ); Following your way: Change your $args like so: $args = array( ‘template’ => ‘%2$l’, ‘term_template’ => ‘%2$s’, ); And then, add this to your functions.php file (this will affect all %l markers!); add_filter( ‘wp_sprintf_l’, function($templates) { // $templates[‘between_last_two’] = sprintf( __(‘%s, and %s’), ”, ” ); // … Read more
Use wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); to get this done. You are adding everything with add_post_meta which will not add category to your post type. wp_set_object_terms( $post_id, sanitize_text_field($_POST[‘some_field’] ), ‘schooltype’, true ); But here I am also not sure how to assign parent-children relationship via wp_set_object_terms, even it’s not mentioned on WordPress codex! I … Read more