Rewrite rule for Custom post type Monthly and Yearly archive

I used this to enable yearly and monthly archive for custom post type. Just drop in this code into your functions.php file. This will add your custom rule right on the top of the Rules array. NB – WordPress uses rules array to store rewrite rules. <?php function wpse22992_custom_post_rewrite( $rewrite_rules ) { $cpslug = ‘contest_recipe’; … Read more

generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?

They are totally differents: generate_rewrite_rules is an action hook and add_rewrite_rule is a function. That said, use add_rewrite_rule() if you want to define custom rewrite rules. Use generate_rewrite_rules to perform an action (from codex) “after all rewrite rules have been created”. That doesn’t mean that you can not add rewrite rules via generate_rewrite_rules, in fact … Read more

add_rewrite_rule – working fine but broken for pagination

Have you tried: The main one: add_rewrite_rule( ‘region/([^/]+)/type/([^/]+)/?’, ‘index.php?taxonomy=region&term=$matches[1]&post_type=$matches[2]’, ‘top’ ); For pagination add_rewrite_rule( ‘region/([^/]+)/type/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?taxonomy=region&term=$matches[1]&post_type=$matches[2]&paged=$matches[3]’, ‘top’ ); Out of curiousity, I replaced one of the ([^/]+) with the literal ‘type’ since that doesn’t seem to be a dynamic variable. If the pagination doesn’t work, try switching the order of when it’s declared, i.e. before … Read more

Custom post type 404s with rewriting even after resetting permalinks

Step 1, add the rewrite tags for custom event year and month query vars, then register the event post type with those tags in the slug argument of the rewrite argument: function wpa83531_register_event_post_type(){ add_rewrite_tag(‘%event_year%’,'(\d+)’); add_rewrite_tag(‘%event_month%’,'(.+)’); register_post_type( ‘event’, array( ‘public’ => true, ‘rewrite’ => array( ‘slug’ => ‘events/%event_year%/%event_month%’ ), ‘has_archive’ => false, ‘hierarchical’ => false, ‘supports’ … Read more

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