Three different post types on homepage

Since you’re not displaying a different amount of posts on the front page and on the paged pages for your main query, you don’t really need to mess around with the offset. All you need is to exclude the three posts you’ve already shown from your query, which you can do with the pre_get_posts action: … Read more

Add 20yrs to post date, and then query

An example, that uses the posts_where filter. If you need to extend a query using the posts_clauses filter, then just exchange $where with $pieces and set $pieces[‘where’] .= instead of $where .=. Just drop that into your functions.php file and add some conditional tag before querying the posts. function filter_where( $where ) { // Add … Read more

wordpress loop for specific category

Pretty sure query_posts is the worst way to query… Always use get_posts from what I’m constantly told. Remove the arguments that you don’t use on the array below. $args = array( ‘posts_per_page’ => 5000, ‘offset’ => 0, ‘category’ => , ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘include’ => , ‘exclude’ => , ‘meta_key’ => , … Read more

the_title(); works in a page template, outside the loop. Why?

The global $post object exists already for singular views before wp_head is called. It is just not filled with all data. The the_title() calls get_the_title() which in turn calls get_post(). And that calls $GLOBALS[‘post’] if no post ID has been passed. See also Generating the ogp tags in theme for a use case.

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