Using a taxonomy value as part of a post URL

Add or replace this to your register_taxonomy (in functions.php): ‘query_var’ => ‘city’, ‘rewrite’ => true Then append this to your functions.php add_filter(‘post_link’, ‘city_permalink’, 10, 3); add_filter(‘post_type_link’, ‘city_permalink’, 10, 3); function city_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, ‘%city%’) === FALSE) return $permalink; // Get post $post = get_post($post_id); if (!$post) return $permalink; // Get taxonomy terms … Read more

Customize category URL

I figured this out by reading this article. It was very simple, all I had to do was: Change the $talks_cat_args[rewrite][slug] from ‘talks’ to ‘talks/category’ (which I had tried before) but missed… Make sure register_taxonomy is before register_post_type. Read the article, but it’s basically because of “how WP_Rewrite works as the process of deciphering permalinks … Read more

Add an access code form to call a unique page based on page without registration

If your code is truly going to be the slug (“secret-page” = example.com/secret-page), you could do something like this… wp_redirect(get_bloginfo(‘url’).”https://wordpress.stackexchange.com/”.$_POST[‘access_code’]); But realize that headers cannot have already been sent, so this needs to happen before get_header(). Some more testing would be needed, but that should get you down the right path in principle. You could … Read more

How to redirect WP post with a specific word in the URL

Try using wp_rewrite: add_action(‘init’, ‘flush_rewrite_rules’); function custom_add_rewrite_rules( $wp_rewrite ) { $new_rules = array( ‘archive/(\d+)’ => ‘/?p=’ . $wp_rewrite->preg_index(1) ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action(‘generate_rewrite_rules’, ‘custom_add_rewrite_rules’); Use the plugin activation hook for the flush_rewrite_rules, because you only want this to happen all the time while developing. In production this should only happen when activating … Read more

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