Custom rewrite to fetch feed data

Seems like a good candidate for add_rewrite_endpoint(). add_rewrite_endpoint( ‘items’, EP_ROOT, ‘item_id’ ); That will register the endpoint /items/<item ID> and also registers the query var item_id, and eliminates the 404 status header/title as well. But the page title would be the site name and you’d probably still want to hook to pre_get_document_title to customize the … Read more

$wp_rewrite->rules is always NULL

Your rewrite rules aren’t showing up because you’re calling it from functions.php before they’ve been defined on a global level. So, you can either hook into an action or pull the rules directly from the DB. Doing it through a hook: function check_my_rewrites() { if ( is_admin() ) var_dump($wp_rewrite->wp_rewrite_rules()); } add_action( ‘init’,’check_my_rewrites’ ); Otherwise, you … Read more

Best way to trigger rewrite rules

init is the recommended hook and no, the rewrite rules will not be overwritten each time the hook fires or that the page is loaded, unless if you call flush_rewrite_rules() or WP_Rewrite::flush_rules() in your callback. add_action( ‘init’, ‘add_my_rewrite_rules’ ); function add_my_rewrite_rules() { add_rewrite_rule( … ); flush_rewrite_rules(); // don’t do this } So please don’t do … Read more

How to query 2 custom post types that need to share a slug?

Note that a filter callback must always return something which is commonly the first parameter passed to the callback. So for example your overwriteQueryVars() function, it must always return the $query because request is a filter hook. Secondly, instead of overwriting the entire query arguments (e.g. by doing $query = array( … ) or $query->query_vars … Read more

Requested URL changes when using custom rewrite rule

this: add_rewrite_rule( ‘membership/member-profile/([^/]+)/?$’, ‘index.php?pagename=member-profile&profile=$matches[1]’, ‘top’ ); should be: add_rewrite_rule( ‘membership/member-profile/([^/]+)/?$’, ‘index.php?pagename=membership/member-profile&profile=$matches[1]’, ‘top’ ); the difference is pagename should contain the parent/child path. also- if profile isn’t a recognized query var, it needs to be added in order to be accessed: function wpse47596_query_vars( $query_vars ){ $query_vars[] = ‘profile’; return $query_vars; } add_filter( ‘query_vars’, ‘wpse47596_query_vars’ );

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