WordPress 404 unless there is a space in url

So after discussing via chat, the problem is with Ps_Perry_Import_To_Post::wp(): final public static function wp() { … if(!empty($_GET[‘pid’]) && empty($_GET[‘r’])) { … wp_redirect(‘/malta-property/’.$_GET[‘pid’].”https://wordpress.stackexchange.com/”.$post_name.’?r=1′); exit(); } if(strpos($_SERVER[‘REQUEST_URI’], ‘/malta-property/’) !== false && empty($_GET[‘r’])) { … if (preg_match(‘/[A-Za-z]/’, $arr2[count($arr2)-1]) && preg_match(‘/[0-9]/’, $arr2[count($arr2)-1])) { // do nothing return null; } else { wp_redirect(‘/?pid=’.$arr1[2]); exit(); } } return null; } … Read more

WP Rewrite the last two parts of the URL

I have finally solved my rewrite rule problem. I used the class outlined in the answer of this wordpress.stackoverflow question. After including that class I used the following code to make it work: // These query vars can be retrieved on the page by using get_query_var( ‘queryvar1’ ); $options = array( ‘query_vars’ => array( ‘queryvar1’, … Read more

Add_query_arg + two times the same argument?

Nilambar’s comment solved this for me. “You can pass two values as comma separated in a single parameter events. And later parse value correctly in your page. – Nilambar” I use this to get posts with tag1 OR tag2: echo ‘<a href=”‘.esc_attr(add_query_arg( ‘events’, ‘tag1,tag2′)).'”>Linkname</a>’; And to get all posts with tag1 AND tag2 simply use … Read more

Remove child category from URL

You can use the post_link_category filter to remove child categories from permalinks: function wpse147453_remove_child_categories_from_permalinks( $category ) { while ( $category->parent ) { $category = get_term( $category->parent, ‘category’ ); } return $category; } add_filter( ‘post_link_category’, ‘wpse147453_remove_child_categories_from_permalinks’ );

Use the plus sign “+” instead of dash “-” in URLs

Mark Jaquith uses “+” as the search query string delimiter in his Nice Search Plugin. Here’s what he does: function cws_nice_search_redirect() { if ( is_search() && strpos( $_SERVER[‘REQUEST_URI’], ‘/wp-admin/’ ) === false && strpos( $_SERVER[‘REQUEST_URI’], ‘/search/’ ) === false ) { wp_redirect( home_url( ‘/search/’ . str_replace( array( ‘ ‘, ‘%20’ ), array( ‘+’, ‘+’ ), … Read more

wp_sanitize_redirect strips out @ signs (even from parameters) — why?

Question why does wp_sanitize_redirect strip out @ signs, exactly? Anybody could anyway try to load a url with an @ sign in it – is there some security issue I’m not thinking about? Just take a look at the source: function wp_sanitize_redirect($location) { $location = preg_replace(‘|[^a-z0-9-~+_.?#=&;,/:%!]|i’, ”, $location); $location = wp_kses_no_null($location); // remove %0d and … Read more

How to change page URLs to “www.site.com/page” instead of “example.com/blog/page” but keep post URLs as “example.com/blog/post”?

You just set the WordPress directory in your WP General Settings to your top-level URL (www.site.com/), then copy index.php to the root directory of your site and modify it to load content from your actual wp directory. Step by step instructions are here: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory I did this for my personal web site: http://dannythorpe.com. The WP … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)