>我有以下代码,因为我正在尝试从我的Wordpress商店为Google购物制作XML提要:
query_posts('post_type=product&showposts=-1&&hide_empty=0');
if (have_posts()) : while (have_posts()) : the_post();
$columns.='<item>';
$columns.='<title>';
$columns.= $post–>post_title;
$columns.='</title>';
$columns.='<link>';
$columns.= 'http://mydomain.co.uk/products/'.$post–>post_name;
$columns.='</link>';
$columns.='<description>';
$columns.=$post–>post_content;
$columns.='</description>';
$columns.='<g:image_link>';
$columns.="http://www.example.com/".$result[$i]['image'];
$columns.='</g:image_link>';
$columns.='<g:price>';
$columns.=$result[$i]['Price'];
$columns.='</g:price>';
$columns.='<g:condition>';
$columns.='new';
$columns.='</g:condition>';
$columns.='<g:id>';
$columns.=$post->ID;;
$columns.='</g:id>';
$columns.='</item>';
endwhile; endif;
但是由于某种原因,我无法获得标题,内容或帖子名称...但是ID将显示正常!?
关于我哪里出错了有什么建议吗?
谢谢。
更改
$columns.= $post–>post_title;
自
$columns.= get_the_title();
法典:get_the_title()
我的 WP 生锈了,但是如果您更改会发生什么
$columns.= $post–>post_title;
自
$columns.= the_title();
想
通了。从互联网上复制了 -> - 似乎是略有不同的字符 - 重新输入它们,现在看起来很好。 谢谢。