Thumbnail Image to go in the post aswell

Use the post thumbnail for the single blog pages too. You can use the add_image_size() function to create an additional image size that is displayed on the blog posts. add_image_size(‘single-post-image’, 650, 250, true); // name, width, height, crop mode Then in single.php the_post_thumbnail(‘image-size’); Simply place the first function in your functions.php, and the second in … Read more

Adding comments to my custom theme

While much of comments implementation became simpler in modern WP versions, it still isn’t quite make-comments-happen button. You will need to put together this part of template, most of related functionality is handled by: wp_list_comments() comment_form() Check native WP themes for complete start to end implementation, although they tend to be a little bulky.

Set a cookie only in single posts

init is too early (it happens before the main query), use the action template_redirect instead. And for the ID use get_the_ID(). Example: if ( is_singular() ) setcookie( get_the_ID(), ‘visited’,time() + ( DAY_IN_SECONDS * 31 ) );

Single.php different behaviour from admin to non-admin

Per a comment, the problem was due to the use of query_posts which clobbers the main query. Please don’t use query_posts. It should be noted that using this to replace the main query on a page can increase page loading times, in worst case scenarios more than doubling the amount of work needed or more. … Read more

Including all post id’s of a custom post type into an array

Save yourself a loop with get_posts and ‘fields’ => ‘ids’. // Default Query function do_query($args = null) { $default_args = array( ‘numberposts’ => -1, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘fields’ => ‘ids’, ); if (null !== $args && !empty($args)) $args = array_merge($default_args, $args); else $args = $default_args; return get_posts($args); } // Customize Query $post_ids … Read more

Which is better and faster ? WordPress Queries or SQL Query

Queries ofcourse. It’s faster… But in this case just please delete you wp site and start with something faster… here is my superfast framework for you… <?php /*Your bunny wrote */ I did tests, 0.0000001 runtime vs WP usually 0.7-2.8 Sarcasm off P/S/ This question have no sence since using direct queries and output of … Read more