在WordPress中将数据检索为数组

在Wordpress中, 假设我在” A”类别下有2个帖子。现在, 我想检索” A”类别的帖子, 如以下格式的数组

A=array(   
           [0] => Array([title]=>'abc'
                        ['description']=>'This is description A1' ), [1] => Array([title]=>'efg'
                        ['description']=>'This is description A2' ) 
)

这样我就可以使用<?php echo A [0] [title];?>显示值

我已经使用过WP_Query(), 但是无法获取明智的数组数据。

有什么办法吗?有人帮忙吗?

提前致谢


#1


你尝试过这样的事情吗?

我做了查询。这只是为了展示如何查询。

$wpdb->get_results( $wpdb->prepare( 
  "SELECT * FROM $wpdb->posts  WHERE (ID = %d  AND post_status = %s)", 15, 'static'), ARRAY_A  );

来源:

https://www.srcmini02.com/63855.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37564.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?