Pre-Populate $wp_query settings with custom rewrite rules and custom template_redirect

I’ve probably found the solution for the above problem. To pre-populate the global variable $wp_query you have to run the query_posts() function with the correct arguments and reset the $wp_query->post with the function wp_reset_postdata(). This must be done on the template_redirect hook or earlier. class Webeo_Download { protected $downloadId; protected $action; public function setup() { … Read more

Use date in the URL of custom post type

Custom post types can not use the “day/name” permalink structure defined in WordPress permalinks settings. You need to add your own rewrite rules to fit your needs. For example: add_action(‘init’,’my_rewrite_rules’); function my_rewrite_rules(){ // Replace custom_post_type_slug with the slug of your custom post type add_rewrite_rule( ‘custom_post_type_slug/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(.+)/?$’, ‘index.php?custom_post_type_slug=’.$matches[4], ‘top’ ); } Note that I’ve not tested the … Read more

How to turn this .htaccess rule into a dynamic rule with add_rewrite_rule, et al?

Try this and follow the same structure to add more rewrite rules or query vars: add_filter(‘query_vars’, ‘my_query_vars’); function my_query_vars( $vars) { $vars[] = “land”; $vars[] = “expert”; return $vars; } // Add the new rewrite rule to existings ones add_action(‘init’,’my_rewrite_rules’); function my_rewrite_rules() { add_rewrite_rule( ‘land/(.+)/?$’ , ‘index.php?land=1&expert=$matches[1]’ , ‘top’ ); } Don’t forget to flush … Read more

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