Define specific category name in PHP

I would advise against query_posts for readability purposes as its easier to make mistakes and you can end up muddled when you nest them. ( You also missed out an equals sign in your syntax. Instead use WP_Query, and check for when no posts are found, e.g. this code: <div class=”category-section”> <h2><?php the_category(); ?></h2> <div … Read more

Custom post type causes php-error in php version 5.2.17

You have to rewrite your code without closures. It could look like this: function wpse54191_plugin_init() { add_post_type(‘Netherlands’, array( ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘comments’) )); } add_action(‘init’, ‘wpse54191_plugin_init’); /* Add Post Type */ function add_post_type($name, $args = array() ) { if ( !isset($name) ) return; $name = strtolower(str_replace(‘ ‘, ‘_’, $name)); $args = array_merge( array( … Read more

Why use foreach to get attachment_id if numberposts is equal to 1?

get_children will return an associative array of posts […] with post IDs as array keys, or an empty array if no posts are found. This statement $attachment_id => $attachment is the same as the more commonly used $key => $value. Using this command echo ‘<pre>’.print_r($attachments,true).'</pre>’; we get the following: resumed version of a get_children with … Read more