urlencode query string in gravity forms confirmation redirect

After digging a little deeper, I found that there is an action hook in Gravity Forms called gform_pre_submission. This allows me to modify a posted value before creating an entry or running the confirmation (see documentation). After that it was pretty basic: add_action( ‘gform_pre_submission_11’, ‘pre_submission_handler’ ); function pre_submission_handler( $form ) { $_POST[‘input_7’] = urlencode(rgpost( ‘input_7’ … Read more

URI returns a post when it should return a 404

WordPress tries to guess what post the user want to see by post name. That is what is making both example.com/new-bikes/ktm/duke/ktm-690-duke-2012/ and example.com/new-bikes/ktm/yamaha/ktm-690-duke-2012/ return the same and “correct” content. What is important is that, if you see at the source code of example.com/new-bikes/ktm/yamaha/ktm-690-duke-2012/, you can see the canonical URL correctly set to example.com/new-bikes/ktm/duke/ktm-690-duke-2012/. User gets … Read more

How to Get a part of URL and put in shortcode?

This should work: function get_name() { $url = “http://domain.com/author/peter”; if (preg_match(“/author/”, $url )) { $lastSlash = strrpos( $url, “https://wordpress.stackexchange.com/”); return substr( $url, $lastSlash, strlen($url)); } } This will return everything after the last slash.

How to Add a Rewrite Rule for Only One Page?

Asumption: You use Apache as your web server. If you already know the page slugs and they won’t change, just add them to your .htaccess file. It’ll be much faster and less complicated. Paste the following Redirect lines at the top of your .htaccess file. Redirect 301 /pagetitle/ /service/pagetitle/ Redirect 301 /pagetitle2/ /another-dir/pagetitle2/ # BEGIN … Read more

Custom Post type permalink structure with custom_post_id

THE ANSWER First of all, this link helped me a lot https://premium.wpmudev.org/blog/building-customized-urls-wordpress It turned out the I don’t need to use add_rewrite_tag(), but to use add_rewrite_rule() to achieve my goal. I wondered why — %job_id% (or even %post_id%, tried them both) is not recognized in my permalink structure. I was expecting that %job_id% will be … Read more

How to delete unused URL?

Whenever you change the slug of a permalink on posts ( and custom post types with post capabilities ), WordPress will save the old slug in the post_meta table with the key _wp_old_slug. On a normal installation the old slug should redirect to the new slug using wp_old_slug_redirect(). There are a couple ways to remove … Read more

Custom page slug without creating a WP page

You’re close, the query var for passing page slug is pagename: add_filter(‘query_vars’, ‘add_account_edit_var’, 0, 1); function add_account_edit_var($vars){ $vars[] = ‘account-edit’; return $vars; } add_action( ‘init’, ‘add_account_edit_rule’ ); function add_account_edit_rule() { add_rewrite_rule( ‘^my-account/([^/]*)/?’, ‘index.php?pagename=my-account&account-edit’, ‘top’ ); } To capture the value in your rule, you need to pass the value in $matches[1]: add_rewrite_rule( ‘^my-account/([^/]*)/?’, ‘index.php?pagename=my-account&account-edit=$matches[1]’, ‘top’ … Read more

Remove query string specific key value

[EDIT] This should work the way you wanted it to: $marca = get_query_var(‘marca’); $marca_arg = isset($marca) && is_array($marca) ? $marca : []; $url_base = remove_query_arg( ‘marca’ ); $n = count( $marca_arg ); foreach ($marcas_terms as $marca_term) { $selected = in_array( $marca_term->slug, $marca_arg ); if ( $selected ) { $marca_arg2 = array_diff( $marca_arg, [ $marca_term->slug ] … Read more