adman4054 Posted July 28, 2023 Share Posted July 28, 2023 Looking for a little help..... Error message --[] operator not supported for strings Error log points to this code: <?php $postnr = 1; $catid = 136; $args = array( 'post__not_in'=> $do_not_duplicate, 'posts_per_page' => $postnr, 'cat' => $catid, ); $wp_query = new WP_Query(); $wp_query->query($args); while ($wp_query->have_posts()) : $wp_query->the_post(); if (of_get_option('of_dnd_simple') == 1) { $do_not_duplicate[] = $post->ID; } ?> <p class="catname"> <?php $catid = $catid; ?> <span><a href="<?php echo get_category_link($catid);?>" data-toggle="tooltip" title="<?php printf(esc_attr__('View all posts filed under %1$s','gabfire'), get_cat_name($catid) ); ?>"><?php echo get_cat_name($catid); ?></a></span> </p> <?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(NULL, 'thumbnail'); ?> Thank you Quote Link to comment Share on other sites More sharing options...
Barand Posted July 28, 2023 Share Posted July 28, 2023 What does this code outputif you put it in the while loop? var_dump($do_not_duplicate); Quote Link to comment Share on other sites More sharing options...
adman4054 Posted July 28, 2023 Author Share Posted July 28, 2023 Thank you Barand for the response -- I do not have the ability to add that right now, when I do I will provide the results, thanks again Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 28, 2023 Share Posted July 28, 2023 Your array definition has a trailing comma. NG Why is that last function being tested? Is it your function? If so how can it be missing. If not, why are you using a function that (somehow) could be missing? You are establishing a query (?) or something from a WP_Query function. But then you make it out to be a query that doesn't look like any sql I have ever seen. Quote Link to comment Share on other sites More sharing options...
requinix Posted July 28, 2023 Share Posted July 28, 2023 42 minutes ago, ginerjm said: Your array definition has a trailing comma. A good portion of the programming community, quite possibly the majority, encourages trailing commas on multi-line statements in languages that support it. 1 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 28, 2023 Share Posted July 28, 2023 So used to typing 'correctly' did not now that I could get away with a hanging comma. Something new today! Quote Link to comment Share on other sites More sharing options...
requinix Posted July 28, 2023 Share Posted July 28, 2023 I wasn't a fan of it for a long time either - things like "it makes diffs cleaner" just don't matter that much to me - but I slowly moved myself over into that camp over the last couple years. Mostly, I decided I kinda liked the consistency of all lines having those commas, rather than all lines except for the last one. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 28, 2023 Share Posted July 28, 2023 Well, to me any line that has a hanging anything is just plain wrong. Every language that I have used that depended on text-structured commands has never allowed us to leave a line 'open' at the end. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.