Title: WP QUERY Multiple post type
Last modified: April 16, 2023

---

# WP QUERY Multiple post type

 *  [benko86](https://wordpress.org/support/users/benko86/)
 * (@benko86)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/wp-query-multiple-post-type/)
 * I am using your plugin and also elementor and code snipper plugin. I have created
   two custom post types with new database table. I was using elementor post widget
   and query id with function in code snippet:
 * function my_query_by_post_types( $query ) {
   $query->set( ‘post_type’, [ ‘furniture’,‘
   mobile’ ] );}add_action( ‘elementor/query/multiple_cpts’, ‘my_query_by_post_types’);
 * but now when I have custom post types in new database table, this query is not
   working. It was working only if custom post types was in the same WP POST table
   and now I have new tables wp_cpt_furniture and wp_cpt_mobile.
 * How to modify this script in code snippet? thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [sebastianklaus](https://wordpress.org/support/users/sebastianklaus/)
 * (@sebastianklaus)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/wp-query-multiple-post-type/#post-16660340)
 * I found out, that I load the plugin functions to late.
 * As a hotfix, you can change one line in cpt-tables/wp-cpt-tables.php from
 *     ```wp-block-code
       add_action('wp_loaded', [$core, 'load']);
       ```
   
 * to
 *     ```wp-block-code
       add_action('plugins_loaded', [$core, 'load']);
       ```
   
 * Give it a try and tell me if it helps
 *  Plugin Author [sebastianklaus](https://wordpress.org/support/users/sebastianklaus/)
 * (@sebastianklaus)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/wp-query-multiple-post-type/#post-16660565)
 * Another question I have: how did you register the custom post types?
 *  Thread Starter [benko86](https://wordpress.org/support/users/benko86/)
 * (@benko86)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/wp-query-multiple-post-type/#post-16663470)
 * I try hotfix, but it is not solution, I have the same problem.
 *     ```wp-block-code
       add_action('plugins_loaded', [$core, 'load']);
       ```
   
 * Another question I have: how did you register the custom post types?
 * I was created post types with CPT UI plugin. I do not know if it is answer for
   your another question…
 * Also at the homepage I can not see posts from wp_cpt_ tables, I can see only 
   posts from wp_posts table. The same problem is in elementor widget, If I select
   custom post types, like posts and other custom post types with separated table,
   in results I see only post from DB table WP_POSTS.
 *  Plugin Author [sebastianklaus](https://wordpress.org/support/users/sebastianklaus/)
 * (@sebastianklaus)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/wp-query-multiple-post-type/#post-16663885)
 * I tried with the actual version 1.2.1 of the plugin. On my test installation,
   I create the custom types by:
    - CPT UI
    - ACF
    - Own PHP files
 * I’ve installed Elementor and also migrated the library to wp_cpt_elementor_library.
   As you can see, it works like a charm. I really don’t know what happens there
 * ![](https://i0.wp.com/i.ibb.co/qjFt3n9/Bildschirm-foto-2023-04-18-um-07-14-47.
   png?ssl=1)
 * ![](https://i0.wp.com/i.ibb.co/YhHPQJY/Bildschirm-foto-2023-04-18-um-07-19-57.
   png?ssl=1)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WP QUERY Multiple post type’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cpt-tables.svg)
 * [Custom Post Type Tables](https://wordpress.org/plugins/cpt-tables/)
 * [Support Threads](https://wordpress.org/support/plugin/cpt-tables/)
 * [Active Topics](https://wordpress.org/support/plugin/cpt-tables/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cpt-tables/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cpt-tables/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [sebastianklaus](https://wordpress.org/support/users/sebastianklaus/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/wp-query-multiple-post-type/#post-16663885)
 * Status: not resolved