Php Wordpress:架构未在其他语言页面中显示
我通过Php Wordpress:架构未在其他语言页面中显示,php,wordpress,Php,Wordpress,我通过index.php文件添加到wordpress站点。基本上,当我导航到localhost时,我能够看到头部呈现的模式。这就是我呈现$context['schema']的地方 然而,当我导航到localhost:3001/es网站的西班牙语版本时,我得到的是一个空数组。我不明白为什么,因为在我的理解中,站点使用的是同一个index.php文件。 现在,模式的实现如下所示: #index.php /** * Setup schema for homepage touts */ $co
index.php
文件添加到wordpress站点。基本上,当我导航到localhost
时,我能够看到头部呈现的模式。这就是我呈现$context['schema']
的地方
然而,当我导航到localhost:3001/es
网站的西班牙语版本时,我得到的是一个空数组。我不明白为什么,因为在我的理解中,站点使用的是同一个index.php
文件。
现在,模式的实现如下所示:
#index.php
/**
* Setup schema for homepage touts
*/
$context['schema'] = array_map(function($tout) {
if ($tout->item_scope) {
return array(
'@context' => 'https://schema.org',
'@type' => $tout->item_scope,
'name' => $tout->tout_title,
'newsUpdatesAndGuidelines' => $tout->link_url,
'datePosted' => $tout->post_modified,
'expires' => $tout->custom['tout_status_clear_date'],
'text' => $tout->link_text,
'category' => 'https://www.wikidata.org/wiki/Q81068910',
'spatialCoverage' => [
'type' => 'City',
'name' => 'New York'
]
);
}
}, $context['homepage_touts']);
$programSchema = array_values(array_filter(array_map(function($program) {
if ($program->getItemScope() === 'SpecialAnnouncement') {
return array(
'@context' => 'https://schema.org',
'@type' => 'SpecialAnnouncement',
'name' => $program->program_name,
'category' => 'https://www.wikidata.org/wiki/Q81068910',
'datePosted' => $program->post_modified,
'expires' => ($program->custom['program_status_clear_date'] ?
$program->custom['program_status_clear_date'] : ''),
'governmentBenefitsInfo' => array(
'@type' => 'GovernmentService',
'name' => $program->program_name,
'url' => $program->structured_data_url,
'provider' => array(
'@type' => 'GovernmentOrganization',
'name' => $program->government_agency
),
'audience' => array(
'@type' => 'Audience',
'name' => $program->audience
),
'serviceType' => $program->category['name']
),
'serviceOperator' => array(
'@type' => 'GovernmentOrganization',
'name' => $program->government_agency
),
'spatialCoverage' => array(
'type' => 'City',
'name' => 'New York'
)
);
}
}, $context['featured_programs'])));
$context['schema'] = array_merge($programSchema, $context['schema']);
$context['schema'] = array_values(array_filter($context['schema']));
if ($context['alert_sitewide_schema']) {
array_push($context['schema'], $context['alert_sitewide_schema']);
}
$context['schema'] = json_encode($context['schema']);
为什么西班牙语页面不加载模式,而主页加载模式?不是所有语言都使用同一个文件吗