page is not redirecting

You need to redirect before any content is sent to the browser. If you had debugging enabled, you’d see errors about headers already being sent. The question is light on detail but if there is a way to avoid the secondary loop and use the main query this should work (though I question the logic): … Read more

Author Specific URL’s in WordPress

here you go: add_action(‘init’, ‘wp_new_flush_rewrite_rules’); //Run this action only ONCE if not you are looking at 2 extra db queries on every page load so dont forget to comment it out function wp_new_flush_rewrite_rules() { global $wp_rewrite; $wp_rewrite->flush_rules(); } add_action(‘generate_rewrite_rules’, ‘new_rewrite_rules’); function new_rewrite_rules( $wp_rewrite ) { $post_type=”post”; $new_rules = array( ‘writer/(.+?)/page/?([0-9]{1,})/?$’ => ‘index.php?post_type=”.$post_type.”&meta_key=writer&meta_value=”.$wp_rewrite->preg_index(1).”&paged=’.$wp_rewrite->preg_index(2), ‘writer/(.+?)/?$’ => ‘index.php?post_type=”.$post_type.”&meta_key=writer&meta_value=”.$wp_rewrite->preg_index(1), … Read more

Permalinks for quote authors

Create a custom taxonomy quoteauthor, activate pretty permalinks, and you get nice URIs automatically. These URIs will not put the author’s name right behind the root, but something like /qa/steve-stevenson/ should be good enough. Here is a sample code as a plugin, you can download it on GitHub <?php # -*- coding: utf-8 -*- /* … Read more

Woocommerce different URL for every table placed in the restaurant

I don’t have a WooCommerce currently to test this out on, so it’s very rough and ready, and may not even work… But, I think the logic is fairly sound. Give this a go: // Store session value for table number add_action(‘init’, ‘store_table_number’); function store_table_number() { if( $_GET[‘dining’] ) { global $tableNo; $tableNo = array( … Read more

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

add_rewrite_rule: Issue converting path to url

The path should just start with wp-content because the generated rewrite rule (which would be added to your .htaccess) is relative to your WordPress installation directory: function addCheckoutRedirect() { add_rewrite_rule( ‘tradeIns’, // I intentionally removed the caret (^) ‘wp-content/plugins/pluginNake/templates/checkout.php’, ‘top’ ); } And here’s how your .htaccess file may look like after the addition of … Read more

Multiple Permalinks for custom post type post

Yes this is possible using add_rewrite_rule(), something along the lines of add_rewrite_rule( ‘test-subject/(\d+)/?’, ‘index.php?post_type=CPT_slug&post_id=$matches[1]’ ); add_rewrite_rule( ‘ts/(\d+)/?’, ‘index.php?post_type=CPT_slug&post_id=$matches[1]’ ); It might be a bit trickier though, since test-subject/test-title and test-subject/post_id are quite similar. Adding the post_id-rule with the 3rd argument as ‘top’ might help.