Why should I put if(have_posts()), is while(have_posts()) not enough?

The WordPress template loader will include the appropriate contextual template file in many circumstances, even if the query for that context returns no posts. For example: The Main Blog Posts Index Category Archive Index (Category exists, but has no posts) Tag Archive Index (Tag exists, but has no posts) Author Archive Index (Author exists, but … Read more

Get post content from outside the loop

You can use get_page() to return the $post object of a static page: $page_id = 302; $page_object = get_page( $page_id ); echo $page_object->post_content; Edit Similarly, you can use get_post() to return the $post object of a post: $post_id = 302; $post_object = get_post( $post_id ); echo $post_object->post_content;

if ( is_home() && ! is_front_page() )

This will display the title of the page when a static page is set to show posts. E.g. I show posts on my homepage… It’ll do nothing. If I, say, show posts on page titled News… It’ll show News in H1. This is used so that the title of the page is shown, whenever posts … Read more

Counting the posts of a custom WordPress loop (WP_Query)?

Correct way of getting the total number of posts is: <?php $count = $custom_posts->found_posts; ?> http://codex.wordpress.org/Class_Reference/WP_Query#Properties Edit: acknowledging @Kresimir Pendic’s answer as probably correct. post_count is the count of posts for that particular page, while found_posts is the count for all available posts that meets the requirements of the query without pagination. Thank you for … Read more

Jquery Slider for profile template

You can use carousel javascript to get the desired output. There are various carousel available, you can use some thing like jcarousel. Download the js and css from the jcarousel website and en-queue it in your theme to use it. Note : You will have to manage the dependencies of it with jQuery. Let me … Read more

How to fix pagination for custom loops?

The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you create … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)