Title: Elementor Custom Query
Last modified: September 28, 2022

---

# Elementor Custom Query

 *  Resolved [yinxingmaiming](https://wordpress.org/support/users/yinxingmaiming/)
 * (@yinxingmaiming)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/elementor-custom-query/)
 * Hi – new to WP Code. Trying to write a custom query and assign it to the Query
   ID in a post widget.
 * I’ve tried many variations on the following, but nothing works. Probably not 
   a WPCode issue, but I thought you folks might have some ideas:
 *     ```
       function custom_query_research_featured ( $query ) {
       // args
       $query_args = ();
       $query_args = array(
               'post_in'   => array( 14116 ),
               );
   
       // exec
       $query = new WP_Query( $query_args );
       }
   
       // ADD ACTION 
       add_action( 'elementor/query/{$query_id}', 'custom_query_research_featured' );
       ```
   
 * Elementor post widget query ID = custom_query_research_featured
 * Thx

Viewing 1 replies (of 1 total)

 *  Thread Starter [yinxingmaiming](https://wordpress.org/support/users/yinxingmaiming/)
 * (@yinxingmaiming)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/elementor-custom-query/#post-16052973)
 * Not a WPCode issue – the Elementor doc references: {$query_id}, which I assumed(
   incorrectly) meant a query id would be interpolated. It needs a literal: ‘elementor/
   query/xxxxxx’

Viewing 1 replies (of 1 total)

The topic ‘Elementor Custom Query’ is closed to new replies.

 * ![](https://ps.w.org/insert-headers-and-footers/assets/icon-256x256.png?rev=2758516)
 * [WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager](https://wordpress.org/plugins/insert-headers-and-footers/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-headers-and-footers/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-headers-and-footers/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [yinxingmaiming](https://wordpress.org/support/users/yinxingmaiming/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/elementor-custom-query/#post-16052973)
 * Status: resolved