ThemeShaper Forums » Thematic

[closed]

Invalid Argument Warning

(2 posts)
  • Started 1 year ago by erikas_boy
  • Latest reply from em hr
  • This topic is not resolved
  1. Hello,
    So, here's what I was trying, I'll get to the error in a moment. I want my blog to only show the two most recent posts on the front page, but show 10 posts on every other page (/2/, category archive, tag archive, search, etc). So I set show posts in the backend to 10, then grabbed this from content-extensions.php


    global $options, $blog_id;

    foreach ($options as $value) {
    if (get_option( $value['id'] ) === FALSE) {
    $$value['id'] = $value['std'];
    } else {
    if (THEMATIC_MB)
    {
    $$value['id'] = get_option($blog_id, $value['id'] );
    }
    else
    {
    $$value['id'] = get_option( $value['id'] );
    }
    }
    }

    /* Count the number of posts so we can insert a widgetized area */ $count = 1;
    while ( have_posts() ) : the_post();

    thematic_abovepost(); ?>

    <div id="post-<?php the_ID();
    echo '" ';
    if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    post_class();
    echo '>';
    } else {
    echo 'class="';
    thematic_post_class();
    echo '">';
    }
    thematic_postheader(); ?>
    <div class="entry-content">
    <?php thematic_content(); ?>

    <?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    </div><!-- .entry-content -->
    <?php thematic_postfooter(); ?>
    </div><!-- #post -->

    <?php

    thematic_belowpost();

    comments_template();

    if ($count==$thm_insert_position) {
    get_sidebar('index-insert');
    }
    $count = $count + 1;
    endwhile;
    }
    }

    Then edited
    while ( have_posts() ) : the_post();
    to
    while ( have_posts() && $count<3 ) : the_post();

    This did what I wanted, 2 on the index, and 10 everywhere else. Except it started throwing an error. Specifically: Warning: Invalid argument supplied for foreach() in /home/content/17/4755417/html/beer/wp-content/themes/TBB/functions.php on line 399, which is the line

    foreach ($options as $value) {

    It continues to throw the error when I remove my edited line. It seems to be a problem with the array, but darned if I can figure out what it is. I (obviously) copied and pasted the code from the content-extensions.php file into my functions.php in my child theme.

    So, am I missing something really obvious? Including a much easier way to do what I want, which I would have expected to find via google/searching here.

    Thanks in advance.

    Posted 1 year ago #
  2. This is likely because the global variable $options is no longer used in Thematic.

    Current versions of thematic handle this code using the helper function thematic_get_theme_opt()

    Posted 1 year ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.