最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rewrite rules - WordPress - replicate same globals, query vars and query for an alternate endpoint

programmeradmin2浏览0评论

We are building a hybrid mobile app for a website.

The app will display a minimal version of the webpage, for example if the website displays post title, post content, sidebar, widgets, etc, then the app would show just post title and the post content for the same post.

Take for example the single post page which is typically rendered by single.php.

For a URL www.example/sample-post, the mobile app will visit a custom HTML endpoint www.example/minimal/sample-post which will be rendered by minimal-single.php

The problem is that the WordPress loop doesn't work inside minimal-single.php because the query variables and the query that is set up for single.php is not set for this endpoint /minimal/sample-post (mimnimal-single.php).

You might say I could use a custom WP_Query to loop through the posts but at the moment there are few restrictions which doesn't allow us to do this.

Is there a way in which we can instruct WordPress to initialise the same globals, query vars and the query used by an endpoint for some other endpoint?

I want to extend this to WooCommerce where the web version can use /product/sunglasses and the app can use /minimal/product/sunglasses and use the WooCommerce loop directly without using WP_Query.

发布评论

评论列表(0)

  1. 暂无评论