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

Hide pages from google and visitors

Add a simple checkbox to the post editor to toggle the generation of a meta field that disallows search engines to index your content. Then hook into wp_head, check for the setting and print that field. Sample code for a plugin: add_action( ‘post_submitbox_misc_actions’, ‘show_noindex_checkbox’ ); add_action( ‘save_post’, ‘save_noindex’, 10, 2 ); add_action( ‘wp_head’, ‘insert_noindex_meta’ ); … 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

Wrong url in sortable column headers & pagination in the admin, when behind a proxy

Ok so apparently this site is behind a firewall or proxy. On lines 491 and 658 in wp-admin/includes/class-wp-list-table.php, replace this line $current_url = ( is_ssl() ? ‘https://’ : ‘http://’ ) . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’]; with if(!empty($_SERVER[‘HTTP_X_FORWARDED_HOST’])){ $hostname = $_SERVER[‘HTTP_X_FORWARDED_HOST’]; } else { $hostname = $_SERVER[‘HTTP_HOST’]; } $current_url = ( is_ssl() ? ‘https://’ : ‘http://’ ) … 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

Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123

If I understand you well, you can do that with add_rewrite_rule(); function to map the url to specific query variables. https://codex.wordpress.org/Rewrite_API/add_rewrite_rule function myfunc_rewrite_rules() { add_rewrite_rule(‘user/?([^/]*)’, ‘index.php?pagename=user&username=$matches[1]’, ‘top’); } function myfunc_username_query_vars($vars) { $vars[] = ‘username’; return $vars; } add_action(‘init’, ‘myfunc_rewrite_rules’); //add query vars (username) to wordpress add_filter(‘query_vars’, ‘myfunc_username_query_vars’); function myfunc_display() { $userpage = get_query_var(‘pagename’); $username = … Read more

Change website URL without breaking links or images? WP 3.3

There is a helpful codex article about moving WordPress: http://codex.wordpress.org/Moving_WordPress. Basically, you need to find/replace the DB for instances of your old domain, and swap them with your new domain. One additional trick I’ve learned when moving WordPress between environments: since WordPress stores the domain in several places as serialized data in the DB, you … Read more