11

You can add your own rewrite rule which will let you tweak the query via URL parameters: add_action( 'init', 'rewrite_photo_url' ); function rewrite_photo_url() { add_rewrite_rule( 'photos/([^/]+)/?$','index.php?page=photos&photo_id=$matches[1]', 'top' ); } If you need to use a custom variable, i.e. 'photo_id', you have to register the variable so ...


5

Your menu slug (5th parameter) can't be the same across multiple pages, and it obviously can't have an & in it, but you can have all the pages you want call the same callback function (the last param). add_submenu_page('upload_manage', "Programs", "Programs", 'manage_options', 'manage-programs', "manage_data"); add_submenu_page('upload_manage', "...


5

I figured it out. I did have some syntax errors in my code. Should have been add_filter instead of add_action. Also, $confirmation is an array and was never returned. I think my brain was just tired from looking at this for so long. Anyways, here's what I did to fix it. add_filter("gform_confirmation", "confirm_change", 10, 4); function confirm_change($...


5

Maybe you're looking for the post__in parameter in WP_Query. $query = new WP_Query(array( 'post__in' => array(23,18,2,199,6,8) ); And then: while ( $query->have_posts() ) { $query->the_post(); /* post loop */ } Take a look at the docs. =D For public queries: post__in is not public queryable by default, so you can just validate and ...


5

It looks like you are using JetPack's Photon which adds query strings to your URLs. According to this thread there is no way to remove them https://wordpress.org/support/topic/how-to-remove-photon-query-string?replies=2 If you want to get rid of the query strings I would suggest deactivating photon, using a CDN which does not add query strings, and using ...


4

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 DISPLAY A PARAMETER FROM THE URL function URLParam( $atts ) { extract( shortcode_atts( array( 'param' => 'param', ), $atts ) ); return $...


4

You could use a PHP session, look in the query object for the request, or use $_GET with your url, but it's not for sensitive information... Something like this; Grab the trip name from the URL $tripname = $_GET['tripname']; Use it in your heading; if(isset($tripname)) echo '<h1>Plan Your Trip To ' .$tripname. '</h1>';


4

You can use add_rewrite_tag to register your custom query variable ('id' in question): add_rewrite_tag('%id%','([0-9]+)'); (The regex tells it only to accepts digits). Then to create your rewrite rule you can use add_rewrite_rule (both of these should be hooked onto init). add_rewrite_rule('^photos/([0-9]+)/?','index.php?p=1234&id=$matches[1]','top');...


4

There is a filter, 'posts_orderby', which allows you to specify your own ORDER BY clauses. In your case, the code would look something like this: add_filter( 'posts_orderby', 'order_by_surname' ); function order_by_surname( $orderby, $query ) { // first you should check to make sure sure you're only filtering the particular query // you want to ...


4

You can use add_query_arg() to add any query parameters you want to a URI, e.g., $redirect_uri = add_query_arg ('page', '4', get_permalink ()) ; $login_uri = wp_login_url ($redirect_uri) ; Or, you could simply use $_SERVER['REQUEST_URI'], which will already contain any query string present in the current page's URI, e.g., $login_uri = wp_login_url ($...


4

The answer to my general question has a very specific answer, and I found the answer by running across this answer to more or less the same problem. Basically GoDaddy hosting does something special to utm_-type query strings. Tech support could provide no detail. In case anyone else runs across this, it looks like something mysterious happens to the ...


3

Your first example is an SQL query, there is no native WordPress function that does this. So that leaves you with some PHP options, explode it, str_word_count, along with sort (or ksort) to then arrange the array alphabetically. This is a very odd way to use this type of data, it should be in a meta box, since you basically have to hack the query in your ...


3

The prepare() method escapes %s. The second piece of code you listed breaks because quotation marks are added to the table name, hence it doesn't match what's in the DB. The first piece of code works because it's a straight string replacement hence matching the name of the table in the database. What is the error message you are getting? HTH


3

First off, don't ever do this: add_action('init', 'flush_rewrite_rules'); Every time WordPress loads, you are going to flush the rewrite rules. You only need to do this once to make sure your rewrite shows up. Second, add_rewrite_tag only takes two arguments, the tag and the regex. If you want to specify a query variable directly, you'll need to do ...


3

Set the query string to p={post_id}. WordPress will redirect it to the proper URI then automatically.


3

In reply to "Update 1": The code worked fine for me. So, I'm still getting a 404 when I go to "mypage" with anything following the pagename, like so: http://example.com/mypage/foo. Because your RegEx pattern is ^category/([^/]+)/?, so the URL you should have visited is http://example.com/category/foo. But then, you shouldn't use category because that "...


2

Depending on how the rules are being generated, you can use the get_query_var() function to get the value of the 'photo' query var. If it's done properly, 'photo' should be an available query var. You'll need to sanitize the value with intval() or similar of course.


2

I'm afraid I don't understand exactly what the problem is so I guess you want just add *product_id* as a query var: function my_add_query_vars( $qv = array() ) { $qv[] = 'product_id'; return $qv; } add_filter( 'query_vars', 'my_add_query_vars' );


2

If you look at how the query works, this is not a case of ... Check to see if the passed query conditions return posts Else run a fallback query What happens is that your conditions are merged with certain defaults via a very complicated sequence of conditionals. At the end of that, you have the SQL that runs to get your posts. The system doesn't check to ...


2

Use a tax_query with a NOT IN operator. $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'sms_premium_posts', 'field' => 'slug', 'terms' => 'Premium', 'operator' => 'NOT IN' ) ) ); $query = new WP_Query( $args ); Now, to make that work on the post edit page via a $_GET ...


2

Use the __() function, just as you see in the the_content() example: <?php echo get_the_term_list( // ID $post->ID, // taxonomy 'book', // Before __( 'Books: ', 'ft' ), // Separator, see http://core.trac.wordpress.org/ticket/7897 __( ', ' ), // After ' ', // Looks like you've added an extra parameter? ...


2

Any url that doesn't point to a file/directory that actually exists is redirected (by .htaccess) to the index.php in the root of your WordPress install. index.php is what actually loads WordPress and its settings etc. It then calls the function wp();, which is responsible for initialising WordPress' actually handling of the request. wp() is little more ...


2

Refer this: Paginate Codex I can see that you are using custom query so you put this below and outside the while loop <?php global $wp_query; $big = 999999999; // need an unlikely integer $args = array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?page=%#%',...


2

Take look at official Query vars. You will see two columns and by then you will get why category__in doesn't work with the URL query string. (basically, the private keywords works only if you specify them in wp_query or so...) About subpost, I am not a hundred percent sure, what it is. In the whole WP_Query it is mentioned only with attachments, take a ...


2

Have you tried adding the third parameter to that call? add_rewrite_tag( '%make%', '([^/]+)', 'make=' );


2

It looks like you can use the ninja_forms_display_init action to populate a field. To get the job ID from the URL you mentioned above you can use the $_GET array. Adapting the code from that documentation page, something like this should achieve what you're looking for: function wpse_158000_populate_field($form_id) { global $ninja_forms_loading; $...


2

I remember a similar issue for the audio shortcode here. There I found a workaround by allowing the empty audio extension. You could try something similar with the video extensions. Here's a demo plugin: <?php /** * Plugin Name: GET Parameters In The Video Shortcode * Description: Allow video files with GET parameters in the video shortcode [video]...


2

You got two options. Either you filter your valid video extentions as @birgire recommended. I remember a similar issue for the audio shortcode here. There I found a workaround by allowing the empty audio extension. You could try something similar with the video extensions. Here's a demo plugin: /** * Allow the empty video extension to ...


2

The server doesn't know what the client is doing with the output and as such, you're limited in what you can assume. You may or may not have params sent in the request, referer, current uri and headers. $_REQUEST['embed_act'] $_SERVER['HTTP_REFERER'] $_SERVER['REQUEST_URI'] get_headers() On the JS side, it might be possible. if(self==top) { //... } ...


2

You need to make only one change in the form, change the first line to: <select name="property_type[]" class="form-control" multiple> Name of the field has to include [] to be considered as an array when it arrives on the server side. In the query string it will be listed as: property_type[]=condo&property_type[]=duplex And, on server side, ...


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