• 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

    (@sebastianklaus)

    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

    add_action('wp_loaded', [$core, 'load']);

    to

    add_action('plugins_loaded', [$core, 'load']);

    Give it a try and tell me if it helps

    Plugin Author sebastianklaus

    (@sebastianklaus)

    Another question I have: how did you register the custom post types?

    Thread Starter benko86

    (@benko86)

    I try hotfix, but it is not solution, I have the same problem.

    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

    (@sebastianklaus)

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP QUERY Multiple post type’ is closed to new replies.