0
votes

I am Wordpress beginer and I want to set multiple queries on a page that lists my posts.

Featured posts

I have front page that lists featured posts from all categories, Categories pages that lists featured posts from current category

Q: Is it better to use My featured posts new category name or to set sticky post (under public - publish options) for posts I want to feature on front page and on categories pages? Every post already have his own category like News so the My featured posts will be the second category.

Query

Let's suppose I'm using category name for featured posts (but then i got permalink to My featured posts category (site/my-featured-posts/2013/07.....) which I don't want (so maybe sticky posts are better solution)

I'm trying to setup query to list featured posts but only from standard post type, not gallery or video

    <?php
    $arg = array(
         'cattegory_name' => 'my-featured-category',
         'posts_per_page' => 5,
         'nopaging' => true,
         'post_status' => 'publish',
         'post_type' => 'post'
    );

    $featured= new WP_Query($arg);

    if ($featured->have_posts()):
            while ($featured->have_posts()) :
                  $featured->the_post();

    ?>

and then below the_title(); ..... and so on

What I get is all articles from all categories.

Q: Also, how to I get popular articles based on views and number of comments for the last day?

Q: How to list posts which have post format video?

Q: Are there any online tools that build wp_query based on criteria?

Thank you.

1
It's category_name, not cattegory_nameRRikesh
funny, but this seems to correct my issue, tired eyes caused this :-) Thanks. Do you know answers to my other questions?Mios Laurie

1 Answers

1
votes

You can also set posts as "featured" using a tag. You can then use tag=featured with WP_Query to get posts tagged with a certain tag ("featured" in this example).

As for your additional questions...

Q1: You can save page views to a flat file or to the WordPress database. Once I used the database to store a UNIX-timestamp as traditional WP post meta for each post page view. As it was a timestamp, I could calculate the age of the page view easily (and I could also run SQL queries to remove post meta that was older than a certain timespan).

Comments can be queried by time ordering too. See WP_Comment_Query.

Of course there are plugins that can do this for you, but for me they included useless bloat I did not need.

Q2: For querying post formats, use the query variable called tax_query as GATEKeeper did in a WP support question: http://wordpress.org/support/topic/post-formats#post-2034414.

Q3: A google query returned a thing called The WordPress Query Generator.