如果元键的值为 x 则 echo
我有 3 段代码,本质上应该做同样的事情,但它们都不起作用,而且都在回响“不工作!”。
元键是 wilcity_belongs_to,值为 2980。这些都基于列表所在的计划。因此,如果列表计划的值为 2980,那么它必须回显“正在工作!”。
$meta = get_post_meta( get_the_ID(), 'wilcity_belongs_to',true );
if( $meta == '2980' ) {
echo "Working!";
} else {
echo "Not Working!";
};
并且
global $wpdb;
$wpdb->get_results( "select * from $wpdb->wpam_postmeta where meta_key = 'wilcity_belongs_to' " );
if ( $wilcity_belongs_to == '2980') {
echo "Working!";
} else {
echo "Not Working!";
};
这
if ( get_post_meta( $post->ID, 'wilcity_belongs_to', true ) == '2980' ) {
echo "Working!";
} else {
echo "Not Working!";
};
是数据库中内容的屏幕截图:数据库 这在表中:wpam_postmeta
请我在这方面获得帮助,我一直在尝试一切。
I have 3 pieces of code that essentially should do the same thing, but none of them are working and they are all echoing "Not Working!".
The meta key is wilcity_belongs_to and the value is 2980. These are all based on what plan a listing is on. So if the listing plan is value 2980 then it must echo "Working!".
$meta = get_post_meta( get_the_ID(), 'wilcity_belongs_to',true );
if( $meta == '2980' ) {
echo "Working!";
} else {
echo "Not Working!";
};
and
global $wpdb;
$wpdb->get_results( "select * from $wpdb->wpam_postmeta where meta_key = 'wilcity_belongs_to' " );
if ( $wilcity_belongs_to == '2980') {
echo "Working!";
} else {
echo "Not Working!";
};
and
if ( get_post_meta( $post->ID, 'wilcity_belongs_to', true ) == '2980' ) {
echo "Working!";
} else {
echo "Not Working!";
};
Here is a screenshot of what is in the database: Database
This is in Table: wpam_postmeta
Please could i get help on this, ive been trying everything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试过这种方法吗?
get_results()
通常返回一个包含结果集的数组。Did you try this way?
get_results()
usually returns an array with the result set.