Hi,
We are migrating our content sites to WordPress + Newspaper theme.
We have noticed that if we use the default WordPress setting “no category” for articles that have no category in the newspaper site, the newspaper theme gives a php error. (article post type, no category)
Also when we activate plugins that create detail pages (and use the newspaper detail page template) without having a proper category set, this gives the same error. (custom post type, no category, example: http://www.flaironline.nl/horoscopen/ram/)
The error:
Warning: Invalid argument supplied for foreach() in /data/home/deploy_monkey/femmes_be/development_current/wp-content/themes/sm-wp-theme-newspaper/includes/wp_booster/td_global.php on line 329 Call Stack: 0.0007 247056 1. {main}() /data/home/deploy_monkey/femmes_be/development_current/index.php:0 0.0015 247536 2. require('/data/home/deploy_monkey/femmes_be/development_current/wp/wp-blog-header.php') /data/home/deploy_monkey/femmes_be/development_current/index.php:17 0.9936 28089864 3. require_once('/data/home/deploy_monkey/femmes_be/development_current/wp/wp-includes/template-loader.php') /data/home/deploy_monkey/femmes_be/development_current/wp/wp-blog-header.php:19 1.0048 28184168 4. include('/data/home/deploy_monkey/femmes_be/development_current/wp-content/themes/sm-wp-theme-newspaper/single.php') /data/home/deploy_monkey/femmes_be/development_current/wp/wp-includes/template-loader.php:75 1.0048 28184328 5. locate_template() /data/home/deploy_monkey/femmes_be/development_current/wp-content/themes/sm-wp-theme-newspaper/single.php:3 1.0052 28184696 6. load_template() /data/home/deploy_monkey/femmes_be/development_current/wp/wp-includes/template.php:531 1.0055 28198392 7. require_once('/data/home/deploy_monkey/femmes_be/development_current/wp-content/themes/sm-wp-theme-newspaper/includes/wp_booster/td_single_template_vars.php') /data/home/deploy_monkey/femmes_be/development_current/wp/wp-includes/template.php:572 1.0055 28199336 8. td_global::load_single_post() /data/home/deploy_monkey/femmes_be/development_current/wp-content/themes/sm-wp-theme-newspaper/includes/wp_booster/td_single_template_vars.php:14
We believe the problem needs to be fixed in the “newspaper theme core”.
In /wp-content/themes/sm-wp-theme-newspaper/includes/wp_booster/td_global.php
An “if” needs to be placed round a foreach of the category array.
if(isset($categories)) {
foreach($categories as $category) {
if ($category->name != TD_FEATURED_CAT) { //ignore the featured category name
self::$primary_category = $category->cat_ID;
break;
}
}
}
It would be nice if this could be fixed.
Hello,
Our theme was built to work with the default wordpress settings and tested to work with these plugins: http://screencast.com/t/SRkrLHoqrgQV Any plugins beyond this list are not tested an could provide conflicts.
If you do not select any categories for your posts, they will be automatically set to the ‘uncategorised’ category. We have not tested nor created any implementation for no category posts. There is no setting that can remove the category entirely. This represents custom implementation and unfortunately it will have to be customized on your side as the theme has been tested to work properly with posts and categories. If the default taxonomy does not suit you, you will have to create custom post types and custom taxonomies for your posts which unfortunately fall beyond what support can offer you.
Thank you!
Hi Bogdan,
Thank you for your reply.
We use default WordPress functions to add our content from a non WordPress site to a WordPress site.
If we use the default WordPress functions for inserting uncategorized posts cat_id=1, we get this error.
Default $cat_id = 1;
$post = array(
'post_date' => date('Y-m-d H:i:s', strtotime($r["object_dateonline"])),
'post_date_gmt' => date('Y-m-d H:i:s', strtotime($r["object_dateonline"])),
'post_content' => $bodytext,
'post_title' => $r["object_title"],
'post_name' => $r["object_title"],
'post_excerpt' => cleanTeasertext($r["object_teasertext"]),
'post_status' => 'publish',
'comment_status' => 'open',
'ping_status' => 'open',
'post_modified' => date('Y-m-d H:i:s'),
'post_modified_gmt' => date('Y-m-d H:i:s'),
'post_parent' => 0,
'post_type' => $post_format,
'comment_count' => 0,
'filter' => false,
'post_category' => array($cat_id), // category ID should be placed here!
);
And maybe you can add this in your next version đ
Adding an “if else condition” around your variable to check if you can use the php function foreach for your variable could be considered as good coding.