You would not do this using SQL, and you don’t need to. Use PHP instead.
For example, this code adds a search parameter to the query, but the value changes depending if the user is logged in:
add_action( 'elementor/query/article_video_together', function( \WP_Query $query ) {
$foo = is_user_logged_in();
if ( true === $foo ) {
$query->set( 's', 'logged in search term' );
} else {
$query->set( 's', 'logged out search term' );
}
$query->set( 'post_type', [ 'article', 'video' ] );
} );
You can do the same using get_user_meta
and the post tag parameters of WP_Query
.
Note that this answer was written assuming that elementor/query/article_video_together
works the same was as the pre_get_posts
action. If it does not, then you need to go to Elementor support or ask in an Elementor community
Related Posts:
- Calling a method from functions.php on a click of a button
- get_the_terms – only top level
- How do I display a user’s previous orders as a select box option on a product?
- Query all posts of a custom taxonomy term
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- How to check if a meta value has already been assigned to any user?
- function to assign user role based on a field from usermeta
- How to abort saving data in save_extra_profile_fields function WordPress?
- Update user profile information from functions.php
- Read array in php?
- Countdown to date function?
- Hierarchical taxonomy list with modificated term links
- If Array Values Match Another Array’s Values, Then
- Shortcode for Listing Users from Meta Value?
- making php value numeric
- Taxonomy term description with style, only if the description exists?
- Uses for function: wp_update_user
- How to change the author box selection on a post to a custom taxonomy
- How to hide a child category and show his parent category
- How to add and subtract user meta values after post meta update
- Include User ID in iFrame URL
- Display current user metadata on WordPress page
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- Get user by meta data key and velue
- Where do I implement this display of User Meta Data, and how to put it in a table?
- Add another role to a user when they click a button?
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- str_replace not preserving whitespace
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Custom Taxonomy as Link
- Limit Taxonomy Parents
- Get category id for a custom category and display it in a class
- Get author meta of all writers
- A better way to write this php function
- How do I change the Go To Categories link in the term_updated_messages
- Display terms on product page with shotrcode
- WordPress different custom tag being displayed in on tag list
- Is it possible to disable a function of a parent theme?
- Hide old attachments from wp media library
- PHP – redirect https to http and www to non-www
- How to overwrite youtube embed?
- Need to get specific data from array
- Generating add_settings_section() calls dynamically
- Sort registered users by post count? (inside admin dashboard)
- How to change a public function inside a class of a plugin?
- Sum custom field values of particular taxonomy
- Function set default image when image not present
- WooCommerce – Reset quantity input field when variation changes
- Trying to establish connection to External Database
- Login/logout in header
- How to put “Read more” link in Custom Excerpt inside p tag?
- Error when adding excerpt to the content through functions.php
- Add data attribute to each li in menu
- Get users that likes the post
- Get the date of the className or classID
- Way to add captions to gallery images by code
- My custom get_the_excerpt() can’t get excerpt by ID
- meaning of (array)function()
- WordPress Options Page Theory Question
- deactivating an active plugin using if page
- How to make container class in PHP
- Copy taxonomy terms from one post to another programmatically
- How do I check or test a WordPress Auto Year Change Script?
- How to use the checked() function to check for a non-empty var
- How to hide the author box of a specific user?
- Add date before entry title in Twenty Twelve
- WordPress theme showing blank page
- Defining multiple categories for showing latest posts
- Pagination Not Working (pages duplicating content)
- Custom functions for string data calculations
- How are these PHP functions applied to a specific page in WordPress?
- The additional fee for the COD payment method not visible in the front-end
- “pre_get_posts” orderby custom date field in different format?
- How to update posts’ custom taxonomy selection?
- Reliable way to add nonce to HTTP Header in WordPress?
- Trying to update Woocommerce meta values
- How can I redefine WordPress wp-content directory programmatically?
- Trim Titles Only On Some Pages
- Custom global variable not working in function
- Embed video from streamtape using direct link
- get_the_author_meta( ‘ID’ ) just return 1
- Enqueue sripts and styles only if function is called
- Site title not showing. Please help me
- Check if post visited first time
- Need to Echo A Url path to show on a wordpress page
- Theme editing “post thumbnail” help
- add a value to an external link query in searchform
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Store stripe info as user_meta
- AJAX Returning Way Too Many Posts
- How to get category pages to look like a certain archive page?
- How to call a specific value within the functions.php file?
- Select area and checkbox data is not saving?
- How to modify this function to exclude also the post belonging to a specific category?
- Suppress errors when using global function
- Warning: filemtime(): stat failed for wp_
- Keep users logged in Without Remember Me
- How to use js variable to php in wordpress functions.php