WordPress Plugin manipulate have_posts()

The standard query for posts uses orderby => ‘post_date’ and order => ‘DESC’. The best candidate for arbitrary sort of posts would be orderby => ‘menu_order’ and order => ‘ASC’. The menu_order is not generally used for posts but it is safe to be used. As suggested by Pieter Goosen use action hook pre_get_posts: add_action( … Read more

Single.php – Get Current Parent Category

The very broad answer for why this doesn’t work is that the internet is stateless. Basically each request for a page is a separate and unique instance from other page requests. Example Let’s say post-1 is in category-1 and category-2. When WordPress loads post-1 on single.php it has no way of knowing how the user … Read more

Pagination 404s on custom query

There are a couple of things I don’t understand here, but I’ll try answering them as I go along. You have a home.php, which I assume is your default homepage. You have one line of code in there, and that is to call a another page template. Here is you code <?php require dirname( __FILE__ … Read more

how to “not” display new posts with a specific category on the main page?

There is even an example in the WordPress codex here for this: http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-3,-8’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category’ ); Just modify the category IDs (replace -3,-8 by your category IDs preceded by the minus sign) and put it in … Read more

How to show latest blog post rather then earliest

There must be something playing with your query (using pre_get_posts) as the default in WP is to load the last created post. Use this WP_Query instead $the_query = new WP_Query( ‘posts_per_page=1&post_type=post’ ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); ?> <h4>Posted on <?php the_time(‘F jS, Y’) ?></h4> <p><?php the_content(__(‘(more…)’)); ?></p> <?php … Read more

WordPress Blog – Grid View

I use the masonry way at the end of my css; /* Masonry Custom CSS for the Grid Style Blog */ /* Masonry container */ body.blog div#content, body.archive div#content { -moz-column-count: 3; -webkit-column-count: 3; column-count: 3; -moz-column-gap: 1em; -webkit-column-gap: 1em; column-gap: 1em; max-width: 100%; margin-left: 20px; margin-right: 20px; } /* Masonry bricks or child elements … Read more