Open Kathryn-gumboots opened 1 week ago
From what I can see in the screenshot, you didn't replace the {query_id} with your custom id that you added under the Query settings in your loop grid.
Here's an example from my blog
Thank you so much @Daveden2 - I knew I might be missing something obvious.
Actually - this still didn't work. The loops post widget is not displaying anything at all, and the straight up posts is displaying an exact copy of the page it is on.
Let's take it step by step. In your PHP code snippet plugin, use PHP like this:
<?php
/**
* Update the query to use specific post types.
*
* @since 1.0.0
* @param \WP_Query $query The WordPress query instance.
*/
function my_query_by_post_types( $query ) {
$query->set( 'post_type', [ 'retreat', 'workshop', 'event' ] );
}
add_action( 'elementor/query/q_post_types', 'my_query_by_post_types' );
Where retreat
, workshop
, and event
are the slugs for your custom post types.
Then, in your posts widget or loop grid widget, add q_post_types
as your query_id
.
Very important Make sure the function name my_query_by_post_types
and q_post_types
are unique. You should not create multiple php functions with the same name
Thank you so very much. I recreated a local host version of my site to with the bare minimum plugins and this worked perfectly.
I am so grateful for your time and patience.
Warm regards, Kathryn
On Mon, 1 Jul 2024 at 16:33, Daveden2 @.***> wrote:
Let's take it step by step. In your PHP code snippet plugin, use PHP like this:
<?php
/**
- Update the query to use specific post types.
- @since 1.0.0
- @param \WP_Query $query The WordPress query instance. */ function my_query_by_post_types( $query ) { $query->set( 'post_type', [ 'retreat', 'workshop', 'event' ] ); } add_action( 'elementor/query/q_post_types', 'my_query_by_post_types' );
Where retreat, workshop, and event are the slugs for your custom post types.
image.png (view on web) https://github.com/elementor/elementor/assets/105490669/4a9f3fa8-4f28-43ed-9222-f2172b4cb561
Then, in your posts widget or loop grid widget, add q_post_types as your query_id.
image.png (view on web) https://github.com/elementor/elementor/assets/105490669/ef0e091a-2f46-436c-a048-4622a6a83cf7
— Reply to this email directly, view it on GitHub https://github.com/elementor/elementor/issues/27873#issuecomment-2199346884, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJQGGMXAGZZGEJLURBINPSTZKDZ4XAVCNFSM6AAAAABKBJW54KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZGM2DMOBYGQ . You are receiving this because you modified the open/close state.Message ID: @.***>
-- Kathryn Hall Meld Creative http://www.vtldesign.com/ Graphic Design | Web Design Illustration | Words p. 0410 719 451
Prerequisites
Description
I want to display 4 different custom post types in the loop post widget. I have followed the instructions as in the Elementor Developer docs (and tried a few other variations too). I have not been successful in making it work. It pulls in pages, not posts. I have tried: • all plugins off (except Elementor, CodeKit & ACF) • placing post widget on a different 'clean' page. • all the different settings in the post widget.
• post widget, loop widget and gallery widget options. • Elementor support, who after a lengthy process of collecting information sent me here.
The ACF key for the post types is in singular, however I have also tried in plural as they appear in the dashboard with no change in the result.
I am not a coder. I know some CSS and can follow PHP instruction and concepts - just :)
Example page with issue: https://tarasprings.com.au/multiple-posts-test/
Steps to reproduce
Use Post Loop Widget.
Add Query Id: my_query_by_post_types.
Add following code to (Theme) using CodeKit set to 'everywhere'
PHP code used: <?php function my_query_by_post_types( $query ) { $query->set( 'post_type', [ 'retreat', 'workshop', 'event' ] ); } add_action( 'elementor/query/{$query_id}', 'my_query_by_post_types' );
Expected behavior
For the post widget to display posts from my multiple custom post types
Isolating the problem
Elementor System Info
Agreement