Load an url with minimal/no DB queries

It is excruciatingly painful to deeply customize WordPress load process. It’s not quite clear if your requirements here are performance related or tied to soemthing else. For your question as stated there would be about following approaches (madness ascending): get rid of actual code causing unwanted queries, altogether or via techniques like caching customize the … Read more

Am I using the flush_rewrite_rules function in the right place?

Considering WordPress Codex flush_rewrite_rules This function is useful when used with custom post types as it allows for automatic flushing of the WordPress rewrite rules (usually needs to be done manually for new custom post types). However, this is an expensive operation so it should only be used when absolutely necessary.… I’d recommend you to … Read more

Rewrite and custom post type: order by custom field not working

If your post type slug is placement, and you set has_archive to true, then the archive WordPress generates is at /placement/. Set has_archive to placements instead and let WordPress add the rewrite rules (which will also handle pagination properly). Then, to order by your meta key, add a function hooked to pre_get_posts, check if the … Read more

Does it still make sense using json endpoint ep_mask now that there’s the new rest api? [closed]

I think you should stop using rewrite endpoints to handle JSON responses. Instead you can and you should use the REST API. So, instead of this: function makeplugins_add_json_endpoint() { add_rewrite_endpoint( ‘json’, EP_PERMALINK | EP_PAGES ); } add_action( ‘init’, ‘makeplugins_add_json_endpoint’ ); And then handle the JSON response at your own, you can and you should do … Read more

Custom rewrite rule for hierarchical custom post type

You’re pretty close. Your rewrite rule is using the wrong query var, pagename should be just name. Here’s a version that works for me on a fresh 4.4.1 install and twentysixteen theme- function bvt_product_init() { $args = array( ‘label’ => __( ‘Product’, ‘domain’ ), ‘description’ => __( ‘Company products’, ‘domain’ ), ‘supports’ => array( ‘title’, … Read more

WordPress add_rewrite_rule() cannot visit lower url levels

I fixed my problem as follows: // Adds rewrite rules for shop post type function gtp_add_shop_rewrite_rules() { add_rewrite_rule( ‘^shop/([^/]*)/([^/]*)/([^/]*)$’, ‘index.php?shop-category=$matches[1]&width=$matches[2]&height=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘^shop/([^/]*)/([^/]*)$’, ‘index.php?shop-category=$matches[1]&width=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^shop/([^/]*)$’, ‘index.php?shop-category=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘gtp_add_shop_rewrite_rules’, 10, 0);

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