Cannot get Post ID
-
hey there!
i code a plugin.
in this little piece of code i want to create an array which contains the title of each post as Key, this actually works great.
but the post id is just not added as value to each key. Dont get the point in it, been looking for mistakes for ages, or at least felt like that.$heldengeschichtenDropdown = array( 'Platzhalter' => 0 ); $args = array( 'category' => 5 ); $heldengeschichten = get_posts( $args ); foreach ( $heldengeschichten as $post ) : setup_postdata( $post ); $arraykey = get_the_title($post); $value = $id; $heldengeschichtenDropdown[$arraykey] = $value; endforeach; wp_reset_postdata();
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Cannot get Post ID’ is closed to new replies.