I’m afraid that you can’t do it this way.
wp_redirect
is a fancy way to send header Location
and the second argument of this function is request status, and not custom variable. (404, 301, 302, and so on).
You can send some variables as get parameters. So you can do something like this:
if ( $post_id ) {
$variable_to_send = '1';
wp_redirect( home_url() .'?my_variable=".$variable_to_send );
exit;
}
Then you can use these variables as $_GET["my_variable']
or register it as custom get variable.
Related Posts:
- Have functions work outside the loop with 404 override
- How to redirect a query string to a “virtual” subdirectory
- WordPress Prevent 404 on missing custom post
- Can wp_query return posts meta in a single request?
- Broken? WP_Query and “attachment” as a post type
- Search custom taxonomy term by name
- Function in array as arguments for WP_Query
- Is there a way to extend WP_query so Custom Post Types can have properties?
- What kind of object type is WP_Query?
- Getting an array out of WPQuery
- WP_Query with meta_value LIKE ‘something%’
- All-in-One Event Calendar: Custom Query – Getting each event Instance [closed]
- Show two random posts from custom post type
- Duplicate Queries
- Counting number of posts with Category B in Category A
- WP_Query inside an existing wp_query stops next post showing
- pagination doesn’t show up for custom post type
- Set div columns in a loop by post count
- How to modify query so it grabs only 90 posts in total?
- cloning a WP_Query
- Placing a div or img in between a post array using WP Query [closed]
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Get posts using WP_Query
- How is WP_Query connected to WP_Post in The Loop?
- Trying to check and see if a post has a featured image outside of the main loop
- Pagination doesn’t work in custom page template [duplicate]
- wp_query a single custom post type?
- How to display the modified post today
- Using pre_get_posts on a specific core/query block
- Efficient way to update multiple post meta
- Does meta_query need numeric values to be cast to integers?
- How to use Meta Value Compare in WP_Query For Max and Min numbers
- Mysql query LIKE not working
- Shortcode to show thumbnail and link for 3 random posts
- Multiple taxonomy And acf filter group by
- Get number of authors
- How to display upcoming events by dat with Modern Events Calendar Lite
- Wp_query Add specific pending posts
- How to Filter Posts by Custom Fields?
- Take all produts by category
- How can I display a custom field from all posts and order them individually from their parent post
- pagination with ‘no_found_rows’ => true,
- Query posts from category A, and from either category B or C
- meta_query not working as expected
- How to retrieve the date on which a post was moved to trash?
- wp_query with parameters
- Query posts with “non set” meta value
- Add filter post_where and passing post_type argument
- WP_Query infinite Loop
- Ordering a mysql style datetime stamp with meta_query
- Advanced WP Query and/or
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- WP Query – order posts by meta field first and then order the rest
- Reusing content from front page on sub page
- Get Child Page IDs by Parent ID
- Wildcard search in WP Query
- Especific order by Custom Field Values in WP_Query
- Create a notification for post field
- Querying a large number of posts including their custom fields data
- Group posts by attachment meta key
- date_query is showing duplicate results
- How to query posts for custom post type with featured image for first 2 post?
- Why is get_the_excerpt returning full content
- Randomly pick one testimonial post
- WP_Query with 2 genres
- Display posts from an array of ID’s
- Date not appearing in custom query
- Custom post type – filter content by custom meta box content
- Trying to output content from page, works locally but not online
- How can I modify the query by adding to the existing query?
- WP_Query Regexp whitespace and end of string
- Custom order of posts in wp_query and different taxonomies
- Update wp_query every week
- Count post meta entries
- use mysql variable in a $wpdb->query to reindex a column?
- wp_insert_post with ACF Fields and WP Meta Query returns no rows until update
- Query WP Posts, then list the taxonomies from those posts
- Query post with content only
- Search with WP_Query, but ignore href URLs in anchor tags?
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- Is meta_key used for ordering, filtering, or both?
- compare for multiple meta values for same key in wp_query
- Merge two queries and remove duplicate
- Convert SQL Query to WP_Query
- Taxonomy Terms That Don’t Exist Display Results
- Why is my query not giving results?
- Get a page ancestor from a most viewed list
- What argument does my function need to echo get_results() query results
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Add pagination to table generated by wp_query
- Adding a Theme Customizer Control for Posts_Per_Page
- using next-page and previous page inside a wp_query
- Custom query from all posts & all child page from one parent page?
- What is wrong with this pagination code?
- wp_query conditionally get posts
- query only direct child and sub-terms of a current term archive
- restrict posts per page
- the_excerpt() not working in custom archive
- I want to capture the last day’s (today) posts in a category in the numbered order in acf
- How do I have multiple metaqueries inside one wordpress query