admin管理员组文章数量:1289834
I am having a problem , I am getting this error, Object of class stdClass could not be converted to string
global $wpdb;
$poster_id = $wpdb ->get_results("SELECT ID from wp_posts WHERE post_status='publish' AND post_type='post' AND post_content LIKE '%[gallery%' ORDER BY ID DESC");
$link_sluger = $wpdb ->get_results("SELECT guid FROM wp_posts WHERE post_name LIKE 'albums%' ORDER BY guid DESC");
foreach ( array_combine($poster_id, $link_sluger) as $posters_id => $linker_slugerr){
global $post;
$post = get_post($posters_id->ID);
$linker_sluger = $linker_slugerr->guid;
if(has_shortcode( $post->post_content, 'gallery' ) ){
echo'<div class="single-album home-last-gallery col-md-4 col-sm-12"> <a href="'.$linker_sluger.'">';
echo na_get_gallery_image_urls($posters_id->ID, $linker_sluger);
echo '</a></div>';
}
}
I am having a problem , I am getting this error, Object of class stdClass could not be converted to string
global $wpdb;
$poster_id = $wpdb ->get_results("SELECT ID from wp_posts WHERE post_status='publish' AND post_type='post' AND post_content LIKE '%[gallery%' ORDER BY ID DESC");
$link_sluger = $wpdb ->get_results("SELECT guid FROM wp_posts WHERE post_name LIKE 'albums%' ORDER BY guid DESC");
foreach ( array_combine($poster_id, $link_sluger) as $posters_id => $linker_slugerr){
global $post;
$post = get_post($posters_id->ID);
$linker_sluger = $linker_slugerr->guid;
if(has_shortcode( $post->post_content, 'gallery' ) ){
echo'<div class="single-album home-last-gallery col-md-4 col-sm-12"> <a href="'.$linker_sluger.'">';
echo na_get_gallery_image_urls($posters_id->ID, $linker_sluger);
echo '</a></div>';
}
}
Share
Improve this question
edited Aug 13, 2019 at 12:21
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Aug 13, 2019 at 12:17
nctincti
135 bronze badges
0
1 Answer
Reset to default 1I solved it. Just change:
foreach( $poster_id as $index => $posterss_id ) {
global $post;
$post = get_post( $posterss_id->ID );
$linker_sluger = $link_sluger[$index]->guid;
/* ... */
}
Full Solution:
global $wpdb;
$poster_id = $wpdb ->get_results( "SELECT ID from wp_posts WHERE post_status='publish' AND post_type='post' AND post_content LIKE '%[gallery%' ORDER BY ID DESC" );
$link_sluger = $wpdb ->get_results("SELECT guid FROM wp_posts WHERE post_name LIKE 'albums%' ORDER BY guid DESC");
foreach( $poster_id as $index => $posterss_id ) {
global $post;
$post = get_post($posterss_id->ID);
$linker_sluger= $link_sluger[$index]->guid;
if( has_shortcode( $post->post_content, 'gallery' ) ){
echo'<div class="single-album home-last-gallery col-md-4 col-sm-12"> <a href="'.$linker_sluger.'">';
echo na_get_gallery_image_urls($posterss_id->ID, $linker_sluger);
echo '</a></div>';
}
}
本文标签: errorsObject of class stdClass could not be converted to string in
版权声明:本文标题:errors - Object of class stdClass could not be converted to string in 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741420076a2377750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论