• I get the following errors, and when I link my pages on facebook they are printed instead of the text in the page. What to do? Thanks in advance
    Please note that ac2-theme is my personalized theme

    Warning: Illegal string offset ‘hide_thumbnail_on_single’ in /htdocs/public/www/wp-content/themes/ac2-theme/header.php on line 6 Warning: Illegal string offset ‘columns’ in /htdocs/public/www/wp-content/themes/ac2-theme/header.php on line 8

Viewing 8 replies - 1 through 8 (of 8 total)
  • what does your header.php file look like? can you share it on pastebin?

    Thread Starter ac2agency

    (@ac2agency)

    can you see this? Click on the underlined text

    thanks for your answer
    best

    i dont think that was your header.php file. that didnt even look like PHP. the error says there is a warning on a certain line of your header.php file. that is what we would have to look at

    Thread Starter ac2agency

    (@ac2agency)

    try this instead?
    https://pastebin.com/EnA5R6d3
    thanks a million

    Thread Starter ac2agency

    (@ac2agency)

    This second file proves that the error is in line 6 and 8 of the first file
    ie. the following highlighted in bold font

    if(is_single() || is_page()) { $post_or_page_id = $post->ID; }
    $data = get_post_meta($post_or_page_id, “custom_meta_values”, true);
    if($data[“hide_thumbnail_on_single”])
    $custom_settings[“layout”][“hide_thumbnail_on_single”] = $data[“hide_thumbnail_on_single”];
    if($data[“columns”])
    $custom_settings[“layout”][“columns”] = $data[“columns”];

    but I don’t know I to solve this since I have not coded this and my web designer is no longer a web designer and unavailable

    try replacing that section with this:

    if (is_single() || is_page()) {
        $post_or_page_id = $post->ID;
    }
    
    $data = get_post_meta($post_or_page_id, "custom_meta_values", true);
    
    if ($data["hide_thumbnail_on_single"]) {
        $custom_settings["layout"]["hide_thumbnail_on_single"] = $data["hide_thumbnail_on_single"];
    }
    
    if ($data["columns"]) {
        $custom_settings["layout"]["columns"] = $data["columns"];
    }

    it looked like some curly brackets were missing

    Thread Starter ac2agency

    (@ac2agency)

    We corrected it, but now we get two errors

    Warning: Illegal string offset ‘hide_thumbnail_on_single’ in /htdocs/public/www/wp-content/themes/ac2-theme/header.php on line 12 Warning: Illegal string offset ‘columns’ in /htdocs/public/www/wp-content/themes/ac2-theme/header.php on line 14

    and

    Warning: Illegal string offset ‘hide_thumbnail_on_single’ in /htdocs/public/www/wp-content/themes/ac2-theme/header.php on line 16 Warning: Illegal string offset ‘columns’ in /htdocs/public/www/wp-content/themes/ac2-theme/header.php on line 20

    I pasted the index php file here <https://pastebin.com/9XcMDMEW&gt;

    Thanks in advance!

    try using single quotes in ALL of your array elements and see if that helps.
    for example, change this:

    if ($data["columns"]) {
        $custom_settings["layout"]["columns"] = $data["columns"];
    }

    to this:

    if ($data['columns']) {
        $custom_settings['layout']['columns'] = $data['columns'];
    }

    The only other thing I can think of is that there isn’t an array or there aren’t any values set for it.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Illegal string offset errors’ is closed to new replies.