请帮助:“在Wordpress中为foreach()提供了无效的参数”
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请帮助:“在Wordpress中为foreach()提供了无效的参数”相关的知识,希望对你有一定的参考价值。
我正在创建WP网站。在首页中,我收到一个错误:
警告:在第108行的/home2/siilverp/public_html/wp-content/themes/mts_steadyincome/page-home.php中为foreach()提供了无效的参数
这是page-home.php的代码:
<?php if(!empty($mts_options['mts_featured_posts']) && !empty($mts_options['mts_featured_post_cat'])) { ?>
<div class="home_article">
<?php
foreach ( $mts_options['mts_featured_post_cat'] as $cat_id ) {
$featured_query = new WP_Query( apply_filters( 'steadyincome_featured_posts_query', array(
'cat' => $cat_id,
'posts_per_page' => 1
) ) );
现在,我发现我必须输入var_dump。然后,出现:
array(84){[“ mts_logo”] =>字符串(0)“” [“ mts_favicon”] =>字符串(0)“” [“ [mts_touch_icon”] =>字符串(0)“” [“ mts_metro_icon” ] =>字符串(0)“” [“ [mts_twitter_username”] =>字符串(0)“” [“ mts_feedburner”] =>字符串(0)“” [“ mts_header_code”] =>字符串(0)“” [“ mts_analytics_code“] =>字符串(0)”“ [” [“ mts_ajax_search”] =>字符串(1)“ 0” [“ mts_sensitive”] =>字符串(1)“ 1” [“ mts_rtl”] =>字符串(1) “ 0” [“ mts_shop_products”] =>字符串(1)“ 9” [“ mts_prefetching”] =>字符串(1)“ 0” [“ mts_lazy_load”] =>字符串(1)“ 0” [“ mts_lazy_load_thumbs”] =>字符串(1)“ 0” [“ mts_lazy_load_content”] =>字符串(1)“ 0” [“ mts_async_js”] =>字符串(1)“ 1” [“ mts_remove_ver_params”] =>字符串(1)“ 1 “ [”“ mts_optimize_wc”] =>字符串(1)“ 1” [“ mts_color_scheme”] =>字符串(7)“#3fc5a4” [“ mts_layout”] =>字符串(8)“ cslayout” [“ mts_background”] = > array(10){[“” color“] => string(7)” #ffffff“ [” use“] => string(7)” pattern“ [” image_pattern“] => string(4)” nobg“ [ “ image_upload”] => string(0)“” [“ repeat”] => string(6)“ repeat” [“ attachment”] => string(6)“滚动“ [” position“] =>字符串(8)”左上“ [” size“] =>字符串(5)” cover“ [” gradient“] => array(3){[” from“] =>字符串(7)“ #ffffff” [“至”] =>字符串(7)“#000000” [“方向”] =>字符串(10)“水平”} [“视差”] =>字符串(1)“ 0 “} [” mts_custom_css“] =>字符串(0)”“ [”“ mts_lightbox”] =>字符串(1)“ 0” [“ mts_sticky_nav”] =>字符串(1)“ 0” [“ mts_show_primary_nav”] => string(1)“ 1” [“ mts_show_footer_nav”] => string(1)“ 1” [“ mts_header_section2”] => string(1)“ 1” [“ mts_header_bottom_text”] => string(17)“下载我的电子书“” [“ mts_header_bottom_button_text”] =>字符串(20)“立即开始赚钱!” [“ mts_header_bottom_button_link”] =>字符串(1)“#” [“ mts_banner_show”] =>字符串(1)“ 1” [“ mts_banner_image”] =>字符串(81)“ https://seiscifrasonline.com/wp-content/themes/mts_steadyincome/images/header.jpg” [“ mts_banner_title”] = > string(34)“今天开始赚取稳定收入!” [“ mts_banner_texts”] =>字符串(156)“ Lorem ipsum dolor sit amet,consectetur adipiscing elit。Morbi at nisl lorem,vel porttitor justo。Nunc non mauris elit。Nam enim massa commodo ut placerat。” [“ mts_button_text”] =>字符串(16)“从这里开始” [[mts_banner_button_bg“] =>字符串(7)”#FF9742“ [” mts_arrow_image“] =>字符串(80)” https://seiscifrasonline.com/wp-content/themes/mts_steadyincome/images/arrow.png“ [[mts_form_image “] =>字符串(80)” https://seiscifrasonline.com/wp-content/themes/mts_steadyincome/images/money.png“ [” mts_ribbon_show“] =>字符串(1)” 1“ [” mts_banner2_show“] =>字符串(1)” 1“ [” mts_social_title“] =>字符串( 66)“加入我们的在线社区中的100,000多人!” [“ mts_banner_social”] => array(5){[“ facebook”] => array(5){[“ group_title”] =>字符串(8)“ Facebook” [“ group_sort”] =>字符串(1)“ 1“ [” mts_banner_icon_title“] =>字符串(8)” Facebook“ [” mts_banner_icon“] =>字符串(8)” facebook“ [” mts_banner_icon_link“] =>字符串(1)”#“} [” twitter“] => array(5){[“ group_title”] => string(7)“ Twitter” [“ group_sort”] => string(1)“ 2” [“ mts_banner_icon_title”] => string(7)“ Twitter” [ “ mts_banner_icon”] =>字符串(7)“ twitter” [“ mts_banner_icon_link”] =>字符串(1)“#”} [“ gplus”] => array(5){[“” group_title“] =>字符串(11 )“ Google Plus” [“ group_sort”] =>字符串(1)“ 3” [“ mts_banner_icon_title”] =>字符串(11)“ Google Plus” [“ mts_banner_icon”] =>字符串(11)“ google-plus” [“ mts_banner_icon_link”] =>字符串(1)“#”} [“ youtube”] =>数组(5){[“” group_title“] =>字符串(7)” YouTube“ [” group_sort“] =>字符串( 1)“ 4” [“ mts_banner_icon_title”] =>字符串(7)“ YouTube” [“ mts_banner_icon”] =>字符串(12)“ youtube-play” [“ mts_banner_icon_link”] =>字符串(1)“#”} [“ rss”] => array(5){[“ group_title “] =>字符串(3)” RSS“ [” group_sort“] =>字符串(1)” 5“ [” mts_banner_icon_title“] =>字符串(3)” RSS“ [” mts_banner_icon“] =>字符串(3) “ rss” [“ mts_banner_icon_link”] =>字符串(1)“#”}} [“ mts_books_title”] =>字符串(51)“ John Smith推荐的读物” [[“ mts_books_image”] =>字符串(0)“” [“ mts_more_book_link”] =>字符串(1)“#” [“ mts_more_book_text”] =>字符串(10)“更多书籍” [“ mts_featured_posts”] =>字符串(1)“ 1” [“ mts_featured_post_cat”] =>字符串(1)“ 1” [“ mts_featured_post_dedup”] =>字符串(1)“ 0” [“ mts_first_footer”] =>字符串(1)“ 0” [“ mts_first_footer_num”] =>字符串(1)“ 4” [ “ mts_footer_slider”] =>字符串(0)“” [“ [mts_copyrights”] =>字符串(73)“ Theme by MyThemeShop” [“ mts_home_post_layout”] =>字符串(8)“ layout-1” [“ mts_full_posts”] => >字符串(1)“ 0” [“ mts_pagenavigation_type”] =>字符串(1)“ 1” [“ mts_home_headline_meta_info”] => array(2){[“启用”] => array(3){[“作者” ] =>字符串(11)“作者名称” [“日期”] =>字符串(4)“日期” [“注释”] =>字符串(13)“注释计数”} [“已禁用”] => array( 0){} } [“ mts_single_post_layout”] =>字符串(0)“” [“ mts_single_headline_meta_info”] => array(2){[“” enabled“] => array(4){[”“ author”] => string(11)“作者名称“ [”日期“] =>字符串(4)”日期“ [”类别“] =>字符串(10)”类别“ [”评论“] =>字符串(13)”评论计数“} [”已禁用“] => array(0){}} [” mts_breadcrumb“] =>字符串(1)” 1“ [” mts_author_comment“] =>字符串(1)” 1“ [” mts_comment_date“] =>字符串(1) “ 1” [“ mts_home_social_buttons”] =>字符串(1)“ 1” [“ mts_social_button_position”] =>字符串(3)“ top” [“ mts_social_buttons”] => array(2){[“启用”] => array(5){[“ facebookshare”] =>字符串(14)“ Facebook Share” [“ facebook”] =>字符串(13)“ Facebook Like” [“ twitter”] =>字符串(7)“ Twitter” [ “ gplus”] =>字符串(11)“ Google Plus” [“ pinterest”] =>字符串(9)“ Pinterest”} [“ disabled”] => array(2){[“ linkedin”] =>字符串( 8)“ LinkedIn” [“ stumble”] =>字符串(11)“ StumbleUpon”}} [>“ mts_posttop_adcode”] =>字符串(0)“” [“ mts_posttop_adcode_time”] =>字符串(1)“ 0” [“ mts_postend_adcode“] =>字符串(0)”“ [” mts_postend_ adcode_time“] =>字符串(1)” 0“ [” mts_custom_sidebars“] =>字符串(0)”“ [” mts_sidebar_for_home“] =>字符串(0)”“ [” [mts_sidebar_for_post“] =>字符串(0)” “” [“ mts_sidebar_for_page”] =>字符串(0)“” [“ mts_sidebar_for_archive”] =>字符串(0)“” [“”“ mts_sidebar_for_category”] =>字符串(0)“” [“ )“” [“ mts_sidebar_for_date”] =>字符串(0)“” [“ mts_sidebar_for_author”] =>字符串(0)“” [“ mts_sidebar_for_search”] =>字符串(0)“” [“ mts_sidebar_for_notfound”] =>字符串(0)“” [“ mts_sidebar_for_shop”] =>字符串(12)“ shop-sidebar” [“ mts_sidebar_for_product”] =>字符串(15)“ product-sidebar” [“ last_tab”] => int(0)}警告:/home2/siilverp/public_html/wp-content/themes/mts_steadyincome/page-home.php中为foreach()提供的无效参数在第108行
从那里,我不知道该怎么办。请注意,我对编程一无所知,也不知道该向谁求助,所以我来到了这个论坛,希望您能为我提供帮助。
非常感谢。
如果始终是一个值,它将起作用:
$cat_id = $mts_options['mts_featured_post_cat'];
$featured_query = new WP_Query(
apply_filters(
'steadyincome_featured_posts_query', array(
'cat' => $cat_id,
'posts_per_page' => 1
)
)
);
以上是关于请帮助:“在Wordpress中为foreach()提供了无效的参数”的主要内容,如果未能解决你的问题,请参考以下文章