foreach() Problem
-
Hello! I am using this code to generate a simple list of all of the posts in a certain category (based on its slug) by looking at the data in a custom field called info. Here is the code:
<?php global $post; $slug = get_post_meta(get_the_ID(), "info", true); $myposts = get_posts('category_name=' . $slug . '&numberposts=-1'); foreach($myposts as $post) :?> <?php the_title(); ?><br /> <?php endforeach; ?>This code works but it has some problems with other plugins. The creator of the plugin told me, “The code you are using is wrong. foreach() is already depreciated. Refer to http://codex.ww.wp.xz.cn/Template_Tags/query_posts”.
I have searched on that link for some time and I am unable to figure out what is wrong. I am very new to wordpress and even newer to php. Any idea what I should change foreach to?
Thanks in advance.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘foreach() Problem’ is closed to new replies.