I do not need to change the standard layout of products.
There is a product page, on it I want to make a link domain/custom-product-view? Id_ of the product and there already work with the product data.

A product has a lot of different attributes and there is a need to create a separate page for managers so that they can see these attributes.Placement option on the original product page is not suitable.
  • Do managers need to be able to change this info?

    I’m not sure what you can (and should) do, but you can make a part that is closed to visitors, where to put the goods in the right format with the necessary data.
    – Ultimate8 Jan 21 '19 at 21:21
  • Ultimate8, the most important task is the custom layout of the entire page, without affecting the main page of the product. To edit or not is a minor, at least a conclusion to be made. – Dr.100 Jan 21 '19 at 21:23
  • Dr.100, do I need a product to have two pages? One for users, the second for managers? – Ultimate8 Jan 21 '19 at 21:25
  • Ultimate8, yes :) – Dr.100 Jan 21 '19 at 21:31
  • Dr.100, only the use of the parameter in the url comes to mind, say


    The sample code did not check:

     function product_template ($template) {if (isset ($_GET ['p'])) {$new_template=locate_template (array ('custom-product-template.php'));if (''!=$new_template) {return $new_template;}} return $template;} add_filter ('template_include','product_template', 99);
    – Ultimate8 Jan 21 '19 at 21:39

1 Answers 1

Do through the final currentthat will be called custom-product-view
  • Can you please a little more? :) – Dr.100 Jan 21 '19 at 22:30
  • Dr.100, Damn well, there are plenty of stubs

    If you use your fingers, you’ve got a class, you’ll figure it out, it works, but you can add everyone there

     class Wpp_Pf_Endpoints {function __construct() {add_action ('init', array (__CLASS__,'add_endpoints'));add_action ('template_include', array (__CLASS__,'change_template'));}/** * Add template for end_point * * @param $template * * @return mixed */public static function change_template ($template) {$points=self :: endpoint_settings();$point=self :: get_current_endpoint();if (empty ($point)) {return $template;} if (get_query_var ($point, false)! == false) {$template_name=$points [$point] ['template'];if (file_exists ($template_name)) {return $template_name;}} return $template;}/** * Add endpoints for query vars. */public static function add_endpoints() {$args=self :: endpoint_settings();foreach ($args as $one_point=>$val) {if (! empty ($one_point)) {$mask =! empty ($val ['places'])? esc_attr ($val ['places']): EP_ROOT;add_rewrite_endpoint ($one_point, $mask);}}}/** * Get page title for an endpoint. * * @return array */public static function endpoint_settings() {$end_points=[];return apply_filters ('wpp_pf_endpoints_args', $end_points);}/** * Get query current active query var. * * @return string */public static function get_current_endpoint() {global $wp;$args=self :: endpoint_settings();foreach ($args as $key=>$value) {if (isset ($wp->query_vars [$key])) {return $key;}} return false;}} new Wpp_Pf_Endpoints();function add_my_test_point ($end_points) {$end_points ['custom-product-view']=array ('template'=>__ DIR__.'/template.php','places'=>EP_ROOT );return $end_points;} add_filter ('wpp_pf_endpoints_args','add_my_test_point');

    add_my_test_point() through the filter wpp_pf_endpoints_args
    adds endpoints'template'- path to point template

    In this example, the point will be available at
    pass through GET something like? id=10 and that's it.

    Well, with the update of permalinks in the code, I didn’t bother to re-save in the admin panel
    – Alive Alpaca Jan 22 '19 at 05:48