48 votes
Accepted

Why "?v=hash" is added to my URLs?

It was woocommerce, it has a setting "geolocalize users with cache support" which adds this parameter to every single url and link. I noticed that the hash appended was the same in every browser on my ...
user avatar
26 votes
Accepted

How to create a shortcode with 1 parameter (atts)

Here is how you should create shortcode. First you will have to define $atts item in get_userdata because $atts is an array. Also I think there is also some issues with uppercase attributes names, so ...
user avatar
  • 8,161
13 votes
Accepted

Trying to use add_action and do_action with parameters

You are using it wrong. add_action: attachs a function to an action hook. In your code, you are attaching alter_item funtion to admin_menu action hook. So, when admin_menu action happens, alter_item ...
user avatar
  • 19.7k
9 votes
Accepted

Why does WordPress automatically redirect URLs with the parameter "name=" to a different page?

In WordPress, name is a reserved term (emphasis mine): There is a complete set of reserved keywords, or terms, in WordPress that should not be used in certain circumstances as they may conflict ...
user avatar
6 votes

use query string in URL to display content on the page

Per the OP's answer within their question: With your help and some Googling, I put together a shortcode that returns the value of any url parameter. Here it is: //THIS IS A CUSTOM SHORTCODE TO ...
user avatar
5 votes

Determine WP_Query parameters from URL

Edited Jul, 07 2014 at 6:28 There are a lot of gotchas with your approach. It will not work if there are any custom rewrite rule, it (probably) will not work if server is IIS and pretty permalink are ...
user avatar
  • 44.6k
4 votes

REST API parameters not working with nginx

If your virtual host looks like this: try_files $uri $uri/ /index.php$args; change it to this: try_files $uri $uri/ /index.php$is_args$args; Adding $is_args (which will print a ? character if ...
user avatar
  • 192
4 votes
Accepted

Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?

I've created a reduced test case that demonstrates that what you want to do is achievable: add_action( 'rest_api_init', function() { register_rest_route( 'wpse/343039', ...
user avatar
3 votes

post_parent array doesn't work

It's not recommended to use query_posts(), check for example this warning note in the Codex: This function isn't meant to be used by plugins or themes. As explained later, there are better, more ...
user avatar
  • 63.9k
3 votes
Accepted

oEmbed vimeo with add_query_arg parameters not inserted to HTML

Take out the var_dump. That is debugging code, it's dumping the variable so that you can see what it is. Edit: Okay, I think you're asking the wrong question here, as did the other person in the ...
user avatar
  • 32k
3 votes
Accepted

get_the_title($postID) OR get_the_title()?

They're both doing the same thing. If you don't pass a post ID, get_the_title() will just use the current post and go about it's business. The performance difference between passing a postID and not ...
user avatar
  • 19.6k
3 votes

Wordpress ajax function parameter value not being passed

First of all you should read the codex on AJAX_in_Plugins Secondly you should look at wp_localize_script to get the value for the admin-ajax url to your javascript. $data = array( 'ajax_url' =&...
user avatar
  • 2,811
3 votes
Accepted

Load custom template for specific GET parameter

Just found an pretty straightforward solution for this problem: add_action( 'template_include', 'account_page_template' ); function account_page_template( $template ) { if( isset( $_GET[ '...
user avatar
  • 388
3 votes

Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Wppr_Public' does not have a method 'amp_support'

The warning message is pretty clear. You're passing method amp_support from class Wppr_Public as callback, but this class doesn;t have such method... So how to fix it? You should find that class and ...
user avatar
2 votes

missing argument 2 when passing arguments to add_action

This problem can be met when hooking in whatever hook that has already been triggered by a precedent do_action (ie. when this_hook has already been mentionned in a do_action within the core files of ...
user avatar
2 votes
Accepted

wp_remote_get() and javascript/noscript situation

This result is expected since wp_get_remote() doesn't include a Javascript engine. It should give you the same result as the View Source option in your browser and fetch the plain HTML document. It ...
user avatar
  • 63.9k
2 votes

How to get variables from fucntion.php to my plugin files

There is three way to use function.php file variable into plugin file. Using global. Make sure you globalize it first. global $my_variable; echo $my_variable; I recommend is using WordPress built-in ...
user avatar
2 votes
Accepted

Returning a value from a PHP page

How can i return a PHP value from a WordPress page to a JQuery function? Use wp_localize_script to create an object and pass it to the JavaScript.
user avatar
  • 3,239
2 votes
Accepted

help me remove this additional parameter in url

The issue is caused by woocommerce. Woocommerce has a setting called Geolocate (with page caching support) which adds this parameter to every your url. The said option can be found in your ...
user avatar
  • 2,811
2 votes
Accepted

Does anyone know all parameters of get_comments()

parent : Comments can be replies to other comments. Every comment has an ID number. When the comment is a reply, then it will have a "parent" which is the ID of the comment it is replying to. Putting ...
user avatar
  • 32k
2 votes

How do I pass arguments for multiple functions hooked to a single action?

The value for the default output should be passed to do_action() as the second parameter. E.g.: do_action( 'my_action', '<p>Default output</p>' ); Note that the above code will not ...
user avatar
2 votes
Accepted

array_filter warning - wp-includes/post.php line 3148

If you check the line from the error notice you should find in WP 4.9.1 the usage of the function array_filter, that need a array as parameter (see the code). Your value inside your array for an post ...
user avatar
  • 16.6k
2 votes

HTTP 403 Error when passing parameters to URL

I can guarantee that somewhere on your technology stack (edge CDN, Firewall, Web Server, WordPress Plugin) that you have something configured that throws a 403 error whenever you try to access a URL ...
user avatar
2 votes
Accepted

Create URL with parameter for JQuery toggle status

You need to process 2 scenarios: When page is loaded with #espanol hash When button is clicked //check for #espanol hash and toggle on page load spanishByHash(); //process toggle on ...
user avatar
  • 251
1 vote

Returning a value from a PHP page

wp_send_json( $result ); if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { wp_die(); } UPD The besat way to use ajax requests with wp is to use wp native ajax actions add_action( '...
user avatar
1 vote

How to get setting from separate file?

Simple answer: Don't add a separate PHP file for AJAX requests. Declare the functions that will be used in your plugin and load them via admin-ajax.php. add_action('wp_ajax_custom_action_name','...
user avatar
  • 4,855
1 vote
Accepted

Query string parameters from custom fields, inconsistent results

OK, here's what I got working in the end. I'm honestly not sure if I've sanitised the parameters correctly so input welcome there! Other than that, all works as intended. Big thanks to Pieter Goosen! ...
user avatar
  • 115
1 vote

Query string parameters from custom fields, inconsistent results

You need to build a proper meta_query. Your code will only work when you have one meta_key set, if you have more than 1, everything will be haywire. Also note, you should never ever use any ...
user avatar
1 vote

Dynamically change page title from URL param

You could do something like this in your header.php file (or where ever you are setting your page titles in your templates) <?php if (isset($_GET['user'])) : ?> <title>Entries from <?...
user avatar
  • 56
1 vote
Accepted

how to load posts to a custom post template after using template_redirect or template_include

here is the full code to force change theme by a reserved wordpress parameter add_action( 'pre_get_posts', 'my_pre_get_posts' ); function my_pre_get_posts($wp_query) { global $wpdb; ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible