Custom Post Type and Taxonomy URL rewrite

I have used my jewelery post type bellows code, You can just replace your post type & taxonomy. Just copy & paste on your functions file. <?php //Register a Jewelry post type. function jewelry_post_register() { $labels = array( ‘name’ => _x( ‘Jewelries’, ‘post type general name’, ‘twentytwelve’ ), ‘singular_name’ => _x( ‘Jewelry’, ‘post type singular … Read more

How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy

After adding print_r($wp_query); to my template and examining the results, I have discovered URL formats that work. I wrote, in my question, that the following format doesn’t work — in fact, it does – if you spell your custom taxonomy name correctly. example.com/?ctxname=term1+term2 Pretty URLs with the ‘+’ and ‘,’ operators (indicating AND and OR … Read more

Multiple endpoints to same page

Okay… here’s how you add the rule. <?php add_action(‘init’, ‘add_my_rule’); function add_my_rule() { add_rewrite_rule(‘^test\/link.*$’,’index.php?pagename=about’,’top’); } ?> This rule will ensure that when you visit a url like http://…/test/link or http://…/test/link<xyz>, you are redirected to the about page (please make sure the slug for about page is ‘about’). Also, http://…/test/, will take you the test page … Read more

Custom post type yearly/ monthly archive permalinks

Here’s an example using add_rewrite_rule to handle years and months for a custom post type where news is the slug. Visit the Settings > Permalinks page in admin to flush rewrite rules after this is added. You could also put this in a plugin and flush rewrite rules on plugin activation. function wpa83797_news_rewrite_rules(){ add_rewrite_rule( ‘news/([0-9]{4})/([0-9]{1,2})/?$’, … Read more

Adding rewrite endpoint breaks static front page

Maybe I did not get this very well, but if you need to just remove ‘foo’ from query vars would not be much more simple to use the ‘request’ filter and remove the var from there? Code needed: add_filter(‘request’, function($query_vars) { return array_diff_key($query_vars, array(‘foo’=>”)); }); It: runs on main query only remove the var for … Read more

Using $_GET variables in the URL?

Try adding the variable to the WordPress’ array of ‘recognised query variables’… add_filter(‘query_vars’, ‘my_register_query_vars’ ); function my_register_query_vars( $qvars ){ //Add query variable to $qvars array $qvars[] = ‘my_error’; return $qvars; } Then the value of ‘my_error’ can be found via get_query_var(‘my_error’). (See Codex) EDIT From Otto’s comment, it’s better to do: add_action(‘init’,’add_my_error’); function add_my_error() { … Read more

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