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

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

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