Intercept page request and add value to it

WordPress doesn’t add the vid to the $_REQUEST array. Instead, it’s saved in a class property — see WP::$query_vars which is an array. And to access the value of items in that array, use get_query_var() like so in your case: $vid = get_query_var( ‘vid’ ); echo “vid value is $vid”;

How to query 2 custom post types that need to share a slug?

Note that a filter callback must always return something which is commonly the first parameter passed to the callback. So for example your overwriteQueryVars() function, it must always return the $query because request is a filter hook. Secondly, instead of overwriting the entire query arguments (e.g. by doing $query = array( … ) or $query->query_vars … Read more

WordPress (admin) posts search GET request filter

function getPostsByCategorySlug(slug) { return site.categories().slug( slug ) .then(function( matchingCats ) { // matchingCats will be an array of the one post that matches // the provided slug if ( ! matchingCats.length ) { throw new Error( `No category found for slug “${slug}”` ); } var catID = matchingCats[ 0 ].id; return site.posts().categories(catID); }); } getPostsByCategorySlug( … Read more

How get child posts in custom post type by ajax?

To retrieve the post details you have to send the data yourself. In your JavaScript code you did not send post id. Update your code like this: data:{ action: “applications_filter”, post_id: current_post_id, //current_post_id should either parsed from DOM or you can write your ajax in PHP file } You must need to send post_id before … Read more

Front-end only $_POST and $_POST requests handling in WordPress plugin

you can use something like this: add_action( ‘admin_post_add_foobar’, ‘prefix_admin_add_foobar’ ); //this next action version allows users not logged in to submit requests //if you want to have both logged in and not logged in users submitting, you have to add both actions! add_action( ‘admin_post_nopriv_add_foobar’, ‘prefix_admin_add_foobar’ ); function prefix_admin_add_foobar() { status_header(200); die(“Server received ‘{$_REQUEST[‘data’]}’ from your … Read more

action is not called after a php request

I just solved it! The problem was, that the php request handling works different in wordpress. There has to be a workaround with a admin_post.php hook: Instead of if( isset($_POST[’email’]) && isset($_POST[‘title’]) ){…} I had to use this hook: add_action( ‘admin_post_nopriv_process_form’, ‘process_form_data’ ); add_action( ‘admin_post_process_form’, ‘process_form_data’ ); function process_form_data() { my_function($_POST[’email’],$_POST[‘title’]); wp_redirect($_POST[‘url’]); } A hidden … Read more

How to query a custom post type with a taxonomy filter but display post type archive page?

The simplest way is, in all honesty, to hook into wp_title and change things, and just be aware that the warnings are there but not showing in production (because you’ve property configured your server). What follows is a kind of hacky solution. If you take a look at get_queried_object… <?php function get_queried_object() { global $wp_query; … Read more

Using database meta_values to calculate new post order using pre_get_posts or a ‘request’ hook

The other day I was thinking on how to make something like this, I would recommend to save the hottnes as a post meta value, that is updated on every vote, save or update, for that you will need the save_posts filter and then you can get the posts ordered with pre_get_posts and a meta … Read more