How to add filter on posts retrieved from WP_Query object?
-
The function below returns all posts within a custom taxonomy called ‘course’.
I have no problem retrieving the custom meta-data as shown in the loop, however, I would to add a filter to posts returned by this function, similar to ‘the_content’ filter for individual posts.
function get_menu_items_by_course($course) { $args['course'] = $course; $posts = new WP_Query( $args ); $menu_items; foreach ($posts->posts as $post) { $menu_items[]['item_name'] = $post->post_title; $menu_items[]['description'] = $post->post_content; $menu_items[]['menu_order'] = $post->menu_order; } //restore post global to current post in the main query wp_reset_postdata(); return $menu_items; }
Has anyone got any ideas on the best way to do this?
Cheers,
Mark
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to add filter on posts retrieved from WP_Query object?’ is closed to new replies.