Archived topic
Pre_get_posts is a hook
1 reply · Started by anabella on January 23, 2020
Hi,
I am using Generatepress + Elementor
I am using a widget in Elementor to display content (I could use the "portfolio" widget of the "posts widget"). I want to display Posts + CustomPostType 1 + CustomPostType 2. This not a native option in Elementor, because the widget only lets you choose 1 query, but after doing some research I got to this article https://developers.elementor.com/custom-query-filter/#Multiple_Post_Types_in_Posts_Widget that says: "After you have set up the Custom Query Filter you can use it to modify the query in the same way WordPress native pre_get_posts hook lets you modify the Query. Using the Custom Query filter is just like any other WordPress native action hook"
Thing is: I have created the Custom Query in the widget, but now I don´t know where I should write the provided code. Should I use Generatepress> Elements> Hooks?
As far as I understood, I should be looking for the hook "pre_get_posts”, but I didn´t find it within Elements > Hooks.
Could you please help me?
Thank you in advance for your suppport!
Hi there,
GP Hooks are only for inserting 'content' into the Theme Templates.
Reading the Elementor Doc - you just need to add the functions ( once amended ) they provided to your child theme functions.php or use the Code Snippets plugin.