Determine if only one image attached to a post/page

That code should get the attachments as array which you should be able to use count() on to determine the total number of images. Example: if ( $attachments ) { if ( 1 == count( $attachments ) ) { // handle single image } else { // handle multiple images } }

WordPress Related Plugin – Adding an image

Have worked it out and have the following code: <?php $rel = $related->show(get_the_ID(), true); foreach ($rel as $r) : echo ‘<a href=”https://wordpress.stackexchange.com/questions/44075/.get_permalink($r->ID).”>’.get_the_post_thumbnail($r->ID, array(50,50)).'<div class=page-related-title>’.$r->post_title.'</div>’.'</a>’.'<br />’; endforeach; ?>

Dynamically change Custom Post Type Template OR Change Permalink?

You can use the rewrite parameter of $args dynamically. Because the post type is registered every time wordpress loads (not just the first time register_post_type() loads), you can set any of the $args dynamically so long as the $post_type slug stays the same. See the codex documentation on register_post_type() for a list of the arguments … Read more

Move wordpress sidebar on homepage up to new position

The best way is to move <div id=”side”> outside of <div id=”content”>, so that you can properly position it next to the slider (<div id=”lof-container”>). Alternatively, you could do it with #maincontent { overflow: visible; } #side { margin-top: -300px; } though this is pretty hackish.

how to set category name for a post

The post_category parameter has to be an array of IDs (int). http://codex.wordpress.org/Function_Reference/wp_insert_post#Parameters Try get_category_by_slug to get the ID, then use it. $category = get_category_by_slug( ‘your-category’ ); $new_post = array( … ‘post_category’ => array( $category->term_id ) ); Alternatively, look into wp_set_object_terms or wp_set_post_terms, using the $post_id of the post you’ve just created. If you need to … Read more