Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在url工作中实现多个类别?_Php_Wordpress - Fatal编程技术网

Php 如何在url工作中实现多个类别?

Php 如何在url工作中实现多个类别?,php,wordpress,Php,Wordpress,通常类别的wordpress结构如下所示。 但我希望我的结构像 我不知道我能以什么方式完成这件事 我想做的就是用这种url,它应该进入到wp内容中的某个页面。之后,我将管理代码 如果有人对这个方向有什么想法 我不知道如何在url中显示3个类别,但要在内容中显示3个类别,可以修改一些主题模板,可能是循环或类别模板,使其显示其中三个: $args = array('numberposts' => $Nposts, 'category' => $id_cat1); $cat1_post

通常类别的wordpress结构如下所示。

但我希望我的结构像

我不知道我能以什么方式完成这件事

我想做的就是用这种url,它应该进入到wp内容中的某个页面。之后,我将管理代码


如果有人对这个方向有什么想法

我不知道如何在url中显示3个类别,但要在内容中显示3个类别,可以修改一些主题模板,可能是循环或类别模板,使其显示其中三个:

$args = array('numberposts' => $Nposts, 'category' => $id_cat1);
$cat1_posts = get_posts($args);
//Loop to write all posts

$args = array('numberposts' => $Nposts, 'category' => $id_cat2);
$cat2_posts = get_posts($args);
//Loop to write all posts

$args = array('numberposts' => $Nposts, 'category' => $id_cat3);
$cat3_posts = get_posts($args);
//Loop to write all posts

通过下面的代码,我能够实现这一点

function site_router() {
global $route,$wp_query,$window_title;
$bits =explode("/",$_SERVER['REQUEST_URI']);
$route->class = $bits[1];
$route->method = $bits[2];
$route->prop1 = $bits[3];
$route->prop2 = $bits[4];
$route->prop3 = $bits[5];
$route->prop4 = $bits[6];
print_r($bits);
if ( $wp_query->is_404 ) {
$wp_query->is_404 = false;
include(get_template_directory() . "/home.php" ); // replace path_to_classes with the actual directory where you keep your class files
/* at the end of your classfile include, you can create the object as $myObject = new Class */
//$myObject->$route->method($route->prop1); // after calling the method, you can set a property in the object for the template

$template = locate_template('ur path/home.php');
$window_title = 'dynamically it will come';
if ($template) {
load_template($template);
die;
}
}
}
add_action( 'wp', 'site_router');

那么你想要category/categoryname/subcategory/subSUBcategory/subSUBsubcategory?或者你希望它一次显示3个类别??我希望它一次显示3个类别。