我有一个侧边栏作为小部件,它根据超级页面id在所有页面上正确显示。我使用一个自定义函数来计算和显示所需的侧边栏。
function is_tree($pid) { // $pid = The ID of the page we\'re looking for pages underneath
global $post;
$postId = null;
$ancestors = array();
if(count($post)>1){
$post = get_post(get_the_ID());
$cat = get_the_category( get_the_ID() );
//print_r($post);
switch($cat[0]->name){
case "Press Release":
$postId = PAGE_ABOUT;
break;
default:
$postId = "00000";
break;
}
if($post->post_type == "event")
$postId = PAGE_ABOUT;
if($post->post_type == "technical_paper")
$postId = PAGE_GEOLOGICAL;
}else{
$cat = get_the_category( get_the_ID() );
if(isset($cat[0])){
switch($cat[0]->name){
case "Press Release":
$postId = PAGE_ABOUT;
break;
case "Technical Paper":
$postId = PAGE_GEOLOGICAL;
break;
}
}
}
if($post){
if($post->post_type == "job_listing")
$postId = PAGE_CAREER;
if($post->post_type == "event")
$postId = PAGE_ABOUT;
if($post->post_type == "technical_paper")
$postId = PAGE_GEOLOGICAL;
$ancestors = get_post_ancestors($post->$pid);
$root = count($ancestors) - 1;
$parent = $ancestors[$root];
}
if( is_page() && (is_page($pid) || $post->post_parent == $pid || in_array($pid, $ancestors)) || ($pid == $postId) )
return true;
elseif( 5581 == $pid && $_REQUEST[\'ir\'] )
return true;
else
return false;
}
使用
widget logic 我在每个不同的侧边栏上使用调用此函数的插件
is_tree(pid)
.
如果浏览到下一页,侧边栏将显示https://gateway.spectrumasa.com:10443/investors/investor-news/news-room/investor-news-story 但是,如果您浏览到下一页,则使用“获取数据”不会。
https://gateway.spectrumasa.com:10443/investors/investor-news/news-room/investor-news-story?ir=http://cws.huginonline.com/S/139450/PR/201411/1873983.xml.
我怎样才能解决这个问题。我对右侧边栏使用相同的方法。
内容是使用一个短代码显示的,该代码获取get数据并解析xml文件以生成输出。
if(!require_once("MagicParser.php")){
echo "Please contact Support";
}else{
$ir_url = $_GET[\'ir\'];
$filename = $ir_url;
}
function myRecordHandler4($record)
{
print "<b>".$record["BODY/PRESS_RELEASES/PRESS_RELEASE/HEADLINE"]."</b> (";
print $record["BODY/PRESS_RELEASES/PRESS_RELEASE/PUBLISHED-DATE"].")";
$tmp = $record["BODY/PRESS_RELEASES/PRESS_RELEASE/MAIN"];
$tmp = str_replace(" ","",$tmp);
$tmp = str_replace("please contact:","please contact:<br/>",$tmp);
$tmp = str_replace("Olset","Olset<br/>",$tmp);
$tmp = str_replace("Spectrum ASA","Spectrum ASA<br/>",$tmp);
$tmp = str_replace("49 65","49 65<br/>",$tmp);
print $tmp."<br />";
//print str_replace(" ","",$record["BODY/PRESS_RELEASES/PRESS_RELEASE/MAIN"])."<br />";
}
function pageInvestmentResultA($record)
{
print "<a target=\'_new\' href=\'".$record["LOCATION-HREF"]."\'><b>".$record["FILE_HEADLINE"]."</b></a> ".$record["FILE-FORMAT"]."<br />";
}
if(!$filename)
echo "No content found!";
else{
MagicParser_parse($filename,"myRecordHandler4","xml|HEXML/");
MagicParser_parse($filename,"pageInvestmentResultA","xml|HEXML/BODY/PRESS_RELEASES/PRESS_RELEASE/FILES/FILE/");
}