Remove current_page_parent from posts page link in WordPress nav menu

I assuming you’re using wp_page_menu() or wp_list_pages(). If so, then what you need to do is hook into the page_css_class filter, e.g., add_filter (‘page_css_class’, ‘my_func’, 10, 5) ; function my_func ($classes, $page, $depth, $args, $current_page_id) { if (/* test condition */) { $classes = array_diff ($classes, array (‘current_page_parent’)) ; } return ($classses) ; } where … Read more

Category and post tag archives do not include posts from custom post type

By default, WordPress will only include the post post type within the post_tag and category taxonomy archives. Use this snippet to add newz posts to the post_tag and category taxonomy archives: add_filter( ‘pre_get_posts’, ‘wpse_newz_taxonomy_archives’ ); function wpse_newz_taxonomy_archives( $query ) { if ( $query->is_main_query() && ( is_category() || is_tag() ) ) { $query->set( ‘post_type’, array( ‘post’, … Read more

Getting all custom posts with a certain category

$blabla = new Query($args); should be $blabla = new WP_Query($args); UPDATE Your actual code should be something like: $args = array( ‘post_type’ => ‘fb’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘fbcate_category’, ‘field’ => ‘id’, ‘terms’ => ’35’, ), ), ‘order’ => ‘DESC’, ‘posts_per_page’ => -1, ); $posts_array = new WP_Query($args); Where taxonomy is your taxonomy … Read more

Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query

SOLUTION: I will post my solution and explain what was the problem and I hope that this post can help someone in the future. As we talk in the small comments the problem, was that I was sending a non existing taxonomy by error and this was causing the AND (0=1). To fix the whole … Read more

Display children and grandchildren of a custom post type

You can create walker for the wp_list_pages() this function use the Walker_Page you can extends him. Walker fo example you put it in the functions.php I added comments with the class name No_Link_First_Child_Walker so you could see what I changed you can search for them. class No_Link_First_Child_Walker extends Walker_Page { public function start_el( &$output, $page, … Read more

How to display recent posts added in several custom post types

You can pass multiple custom post types in an array for ‘post_type’, as in: ‘post_type’ => array(‘books’, ‘stories’, ‘movies’) Your code seems to try to do this, but the syntax is a bit off, it should be: $recent_posts = wp_get_recent_posts( array( ‘post_type’ => array( ‘books’, ‘stories’, ‘movies’ ), ) ); You can find more details … Read more

How can I show some description in the “All Posts” view of a custom post type in Dashboard?

The filter views_{$this->screen->id} is fired just after the title of post edit screen has been print to screen, so it’s a safe place to just echo what you want. So you can simply check here: function post_type_desc( $views ){ printf(‘<h4>%s</h4>’, __(‘Your description here.’) ); // echo return $views; // return original input unchanged } add_filter(“views_edit-POST_TYPE_HERE”, … Read more