首先,我为我的英语表示歉意,这不是我的母语。
我的问题是,当使用“ wp_json_encode”时
我正在尝试做这样的事情:
$datawpap["breadcrumb"] = [
"@type" => "BreadcrumbList",
"numberOfItems" => 2,
"itemListElement" => [
"@type" => "ListItem",
"position" => 1,
"item" => [
"name" => get_bloginfo( 'name' ),
"url" => home_url(),
"description" => bloginfo('description')],
"@type" => "ListItem",
"position" => 2,
"item" => [
"name" => get_the_title(),
"url" => home_url( add_query_arg(null, null)),
"description" => get_the_excerpt()],
]];
当我测试输入代码时,仅执行代码的第二部分,我更了解它是Wordpress的一个问题,但是由于我缺少它,所以我可能知道了一些PHP语法问题,我并不知道PHP。我以为我会把它贴在这里,
这是另一个示例:
"hasPart" => [
"@type" => "SiteNavigationElement",
"SiteNavigationElement" => array (
"position" => 1,
"name" => get_the_title(),
"url" => home_url( ),
"id" => home_url() . '#site-navigation',
"position" => 2,
"name" => get_the_title(),
"url" => home_url( ),
"id" => home_url() . '#site-navigation',
)
]
在这种情况下,在以后我想出代码的时候,我想添加更多的内容,然后再添加两个站点导航输出,因此多个“ name”,url”一个接一个。EG“ name” =>“ home”,“ url“ => website.com,”名称“ =>服务,” url“ => website.com/services,”名称“ =>关于,” url“ => website.com/about/等... >
谢谢!