Randomise results from a category page?

You can actually change any of the query parameters (like the order) by adding them to the url. For instance, the sample url below would randomize the posts on the category archive every time you refreshed, randomizing the results. http://sample.com/category/uncategorized/?orderby=rand Below is a basic form with the orderby value that would refresh whatever page/template it … Read more

Loop.php vs looping inside template file

Depends on whether you would use that single-loop in more places. If you’re only using it in one place and that will remain the case, do it within single.php, if you’re going to be reusing it elsewhere, I’d highly suggest using a single-loop template part.

How to order posts tag by tag?

Like Eugene mentioned in his answer you need to run a query for each tag. I would create a foreach loop that went through each tag then queried the latest 2 posts from each. $tags = get_tags(); foreach ( $tags as $tag ) { echo ‘<h3>’ .$tag->name. ‘</h3>’; $tag_query = new WP_Query( array( ‘tag_id’ => … Read more

WP_Query not looking at child category

You’ll have to get the child or parent categories yourself and pass all the IDs as an array via the category__in argument of WP_Query. You can use get_ancestors to get the top parent category, and get all child categories of that parent via the child_of argument of get_categories.

Build a content and excerpt grid loop with paging and options for # of posts

The $wp_query properties allow “alot” Actually it’s not that hard if you use parts of the $wp_query object like current_post. Here you can see some examples that make some tricky use of things like is_paged(), $wp_query->current_post and $wp_query->posts_per_page. You can switch MarkUp depending on if you’re on the first or later pages, if you got … Read more

Rearranging posts based on categories

May be it’s a bad idea, but it’s the only. Don’t print posts immediately, but collect them in different variables: one for category “test”, one for the rest. <?php $w_h = $w_d = $last = 0; // init variables to concatenate content later $primary_posts = $secondary_posts=””; // empty array to fill later $category_names = array(); … Read more

Category as Class for Custom Post Type

This is expected (or at least: designed) behavior. Here is a portion of the Codex on that: The post_class CSS classes appear based upon the post pageview Conditional Tags as follows. Category Category template files and pageviews displaying posts feature the class selectors: post post-id category-ID category-name Of course, you can hook a custom filter … Read more

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