Can’t get a custom template taxonomy page to display

I found this code; function ftc_flush_rewrites() { global $wp_rewrite; $wp_rewrite->flush_rules(); } function ftc_add_rewrites() { global $wp_rewrite; $ftc_new_non_wp_rules = array( ‘find/(this)’ => ‘/addit.php?here=$1’, ); $wp_rewrite->non_wp_rules = $ftc_new_non_wp_rules + $wp_rewrite->non_wp_rules; } add_action(‘generate_rewrite_rules’, ‘ftc_add_rewrites’); add_action(‘admin_init’, ‘ftc_flush_rewrites’); in this thread http://wordpress.org/support/topic/writing-wp_rewrite-gtnon_wp_rules-to-htaccess …not sure if that addresses the problem but good luck!

Dynamic Endpoints

10up engineering best practices as a great example on how to achieve that. You basically add a new rewrite tag and a new rewrite rule and then using the template_redirect action you return your custom action. Here is the code: add_action( ‘init’, function() { add_rewrite_tag( ‘%model%’, ‘([^/]+)’ ); add_rewrite_rule( ‘cars/([^/]+)/?’, ‘index.php?model=$matches[1]’, ‘top’ ); } ); … Read more

Custom page with variables in url. Nice url with add_rewrite_rule

I think the add_rewrite_tag() is not needed, and can be replaced with adding the variables to the public query vars directly: // Either directly (in your init hook): $wp->add_query_var( ‘var1’ ); $wp->add_query_var( ‘var2’ ); // Or via a filter: add_filter( ‘query_vars’, ‘wpse12965_query_vars’ ); function wpse12965_query_vars( $query_vars ) { $query_vars[] = ‘var1’; $query_vars[] = ‘var2’; return … Read more

Custom post type permalink endpoint

A couple things. First, your function names need to be prefixed with something unique. WordPress is a big ecosystem, and someone else has probably used all the generic function names you can think of. Second, add_rewrite_endpoint takes care of adding query variables for you. So you don’t need this: add_filter( ‘query_vars’, ‘add_query_vars’); function add_query_vars($vars){ $vars[] … Read more

WordPress Rewrite Rules for Custom Post Type and Taxonomy

Hope this can solve your problem function my_custom_post_type() { $labels = array( ‘name’ => _x(‘Projects’, ‘post type general name’), ‘singular_name’ => _x(‘Project’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘project item’), ‘add_new_item’ => __(‘Add New Project’), ‘edit_item’ => __(‘Edit Project’), ‘new_item’ => __(‘New Project’), ‘view_item’ => __(‘View Project’), ‘search_items’ => __(‘Search Projects’), ‘not_found’ => … Read more

Custom rewrite rules for archive page and single post

I found solution! A Monkeyman Rewrite Analyzur plugin was very helpful: https://wordpress.org/plugins/monkeyman-rewrite-analyzer/ So now, I have such working urls… single.php: /magazine-name/issue-year/issue/article-name archive.php: /magazine-name/issue-year/issue /magazine-name/issue-year /magazine-name On a custom post editor page in wp-admin I use Advanced Custom Fields plugin for issue year and issue. You can also define meta fields by yourself. Next I added … Read more

Why does everybody hook add_rewrite_rule on init

You are right saying that without flushing rules, add_rewrite_rule() does not work, and the reason is that WordPress fetches rules from database, and add_rewrite_rule() does not add the rule to database. However, is not possible to use admin_init and the reason is that admin_init is too late. WordPress sometimes calls flush_rewrite_rules() on admin screens before … Read more

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