• Good Day Guys

    I installed a new theme, which a absolutely love, and my client loves it as well, but I get an error on the index page which I been trying to sort out in the past few days.

    I get this error:

    Warning: array_search() [function.array-search]: Wrong datatype for second argument in /home/……/wp-content/themes/templatename/index.php on line 15

    The section of the code on the index page is `

    }
    $ctr = 5;
    if (have_posts()) : while (have_posts()) : the_post();
    if (array_search(get_the_ID(), $do_not_duplicate) !== false);
    ?>

    <?php $feature_img = get_post_meta($post->ID, ‘Image’, ‘true’);
    $feature_desc = get_post_meta($post->ID, ‘img_description’, ‘true’); ?>
    <?php if ($ctr < 2) {
    $ctr++;
    }`

    It might be a simple solution, but I can’t figure it out for the life of me.

    Thank you in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Where is $do_not_duplicate being set, is it an array?

    It looks like a boolean, in array looks for a needle (single value) in a haystack (array).

    The if statement is not doing any conditional code, so I cannot see what it does?

    David

    Thread Starter albertosala

    (@albertosala)

    Thanks for the reply first of all.

    yes the $do_not_duplicate is being sent to the array, of Featured Posts.

    This is the link of the theme that I’m using, http://freegirlythemes.com/demo/?wptheme=Melrose

    and this is the code of the index page.

    http://pastebin.com/GASix7si

    But the code is still not right, I would expect a : or { after the if statement.

    <?php if($is_sunny) : ?>
        <h1>Hey it is Sunny</h1>
    <?php endif; ?>

    Or

    <?php
    if($is_sunny) {
        echo '<h1>Hey it is Sunny</h1>';
    }
    ?>

    However to stop the error check if it is an array!

    if( is_array($do_not_duplicate) && array_search(get_the_ID(), $do_not_duplicate) !== false);

    HTH

    David

    David is right; i downloaded the theme, and there is more code in the template.

    there is also an include of a gallery file before the error line, where the $do_not_duplicate array is filled with content.

    with that include gone, the line
    if (array_search(get_the_ID(), $do_not_duplicate) !== false)
    can and should be deleted from the template.

    Thread Starter albertosala

    (@albertosala)

    guys thanks for your replies, i tried everything you guys recommended but it still won’t work, I think i might have to give up on this template.

    Thanks again very much appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘array_search() [function.array-search]: on the index page’ is closed to new replies.