blog_list order

resolved (23 posts) (4 voices)

  1. bigmojo
    Member

    I have used the blog shortcode to insert a blog category on a certain page in list format.

    All of the blogs are posting in chronological order (oldest to newest). Is this the expected behavior?
    How can I reverse the order with the shortcode (newest to oldest)?

    Edit: Here's the link: LINK

    Posted 5 years ago #
  2. Elliott
    Support

    Hello bigmojo,

    Open up /wp-content/themes/[your_theme]/lib/shortcodes/14-blog.php and on lines 260 - 269 you should see this,

    $blog_query->query(array(
    	'post__in' => $post_in,
    	'category__in' => $category_in,
    	'tag__in' => $tag_in,
    	'post_type' => 'post',
    	'showposts' => $showposts,
    	'nopaging' => 0,
    	'offset' => $offset,
    	'ignore_sticky_posts' => 1
    ));

    Change it to this,

    $blog_query->query(array(
    	'post__in' => $post_in,
    	'category__in' => $category_in,
    	'tag__in' => $tag_in,
    	'post_type' => 'post',
    	'showposts' => $showposts,
    	'nopaging' => 0,
    	'offset' => $offset,
    	'ignore_sticky_posts' => 1,
    	'order' => 'ASC',
    ));

    If that's not it then switch it the "ASC" part to "DESC".

    Posted 5 years ago #
  3. bigmojo
    Member

    How do I change this so that a theme update doesn't override?

    Would a child theme be required?

    Posted 5 years ago #
  4. Elliott
    Support

    There wouldn't be a way with a child theme. We are probably going to add a "custom" option to the shortcode soon where you can set custom query parameters.

    Posted 5 years ago #
  5. bigmojo
    Member

    opened up the 14-blog.php file and it already has the ascending order in the associative array. I understand to change this to DESC.

    again, I just want to make sure that the theme update won't override the change.

    Posted 5 years ago #
  6. bigmojo
    Member

    Thanks for the info, Elliott. I look forward to seeing the custom options. Even if the Order was the only parameter that could change. It seems as though when displaying blogs, descending should be default so that new posts appear first.

    I appreciate your help (you can probably disregard my last post on this topic)

    Posted 5 years ago #
  7. bigmojo
    Member

    Okay, I'm back. Although switching the order parameter to descending works when viewing in Firefox, I'm not having any luck in Internet Explorer. I've checked versioning and it appears all versions of IE are displaying in ASC order even though I've specified DESC.

    Suggestions?

    Posted 5 years ago #
  8. Elliott
    Support

    Try deactivating your plugins and clear your browser cache.

    Posted 5 years ago #
  9. bigmojo
    Member

    That appears to have solved the problem. I have reactivated my plugins (and cleared the cache again) just to make sure it stayed in the "right" order.

    Do you know why this would solve the IE issue? When you suggested this method, I thought you implied that one of my plugins was causing a conflict in the PHP. I have one that lets me insert blocks of php and I just happen to be using some parameters that display blogroll links in DESC order. Fortunately, this was not the case as I reactivated all of them (as stated earlier) and everything is fine.

    Posted 5 years ago #
  10. Elliott
    Support

    It was probably just an old cache.

    Posted 5 years ago #
  11. webmasterobservatoriobioetica
    Member

    hi
    I have the same problem. but, in my case, I think that is because I'm using the category__and. How can I order the post?

    14-blog.php

    line 245

    if( trim( $pagination ) == 'true' ) {
    $paged = mysite_get_page_query();
    $blog_query->query(array(
    'post__in' => $post_in,
    'category__and' => $category_in,
    'tag__in' => $tag_in,
    'post_type' => 'post',
    'posts_per_page' => $showposts,
    'paged' => $paged,
    'offset' => $offset,
    'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    ));

    } else {

    $blog_query->query(array(
    'post__in' => $post_in,
    'category__and' => $category_in,
    'tag__in' => $tag_in,
    'post_type' => 'post',
    'showposts' => $showposts,
    'nopaging' => 0,
    'offset' => $offset,
    'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    ));
    }

    Posted 4 years ago #
  12. Elliott
    Support

    Change this line,

    'order' => 'DESC',

    To this,

    'order' => 'ASC',

    Or if your wanting to order them by the title then change this line,

    'orderby' => 'date',

    To this,

    'orderby' => 'title',

    Posted 4 years ago #
  13. webmasterobservatoriobioetica
    Member

    Thanks, but ... does not work :( if I write category__in, the post listed in order, but with: category__and not work.
    I want a Blog_list, with post with category 1 AND 2, with the oldest post appear at the end, and recent first.

    With the category__and appear only the post whit the category 1 AND 2, but list in order to create (not publish)...

    :S

    Posted 4 years ago #
  14. Elliott
    Support

    If your wanting multiple categories then you do not need to edit anything. Just select whatever categories you want to use in the shortcode options, http://mysitemyway.com/docs/index.php/Blog_Shortcode.

    See our shortcode generator, http://mysitemyway.com/docs/index.php/Using_the_Shortcode_Generator.

    Posted 4 years ago #
  15. webmasterobservatoriobioetica
    Member

    Hello, I do not want to display multiple categories, I want to show a post who belongs to various categories.

    eg

    Categories:

    shoes
    clothes
    reds
    blue

    I want to put a blog_list, with all the post that are, BLUE SHOES, NO red shoes, NO blue dress, blue shoes ONLY.

    For that, wp use category__and, but if I use category__and, the post is not list by publication date, from newest to oldest... :(

    Posted 4 years ago #
  16. Elliott
    Support

    Are you sure it's not a problem with your post dates? The way you switch the order is by doing this, http://mysitemyway.com/support/topic/blog_list-order#post-110467.

    Posted 4 years ago #
  17. webmasterobservatoriobioetica
    Member

    Yes, if I put category__in, the order it's ok, but, if I put category__and is not correct
    CATEGORY__IN = WORKS:

    if( trim( $pagination ) == 'true' ) {
    	$paged = mysite_get_page_query();
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__in' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'posts_per_page' => $showposts,
    		'paged' => $paged,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    
    } else {
    
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__in' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'showposts' => $showposts,
    		'nopaging' => 0,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    }

    CATEGORY__AND = NOT WORK

    if( trim( $pagination ) == 'true' ) {
    	$paged = mysite_get_page_query();
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__and' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'posts_per_page' => $showposts,
    		'paged' => $paged,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    
    } else {
    
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__and' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'showposts' => $showposts,
    		'nopaging' => 0,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    }

    It does not work if you use category__and. I need to use category__and :(

    Attachments

    1. 6-Date-DESC-Category_in.jpg (60.4 KB, 0 downloads) 4 years old
    2. 1-Date_DESC-category_and.jpg (57.9 KB, 0 downloads) 4 years old
    Posted 4 years ago #
  18. Elliott
    Support

    Try contacting the Wordpress support forums, http://wordpress.org/support/, for this customization.

    Posted 4 years ago #
  19. webmasterobservatoriobioetica
    Member

    In the WP Forum, I'm see this, I think that I write correct, but.. don't work, please, can you helpme??

    "At 2.3 this combination will return posts belong to both Category 1 AND 3, showing just two (2) posts, in descending order by the title:

    query_posts( array( 'category__and' => array(1,3), 'posts_per_page' => 2, 'orderby' => 'title', 'order' => 'DESC' ) );
    "

    Posted 4 years ago #
  20. webmasterobservatoriobioetica
    Member

    I've been looking and sort posts with category__and and is done. But it does not work with this theme.

    Can you see if the problem is only with this theme? And how to fix it?

    thanks

    Posted 4 years ago #
  21. webmasterobservatoriobioetica
    Member

    I have the solution!!!

    in the wp-includes/query.php line 2283 (Wordpress V3.5)

    Change this

    `if ( !empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries ) ) {
    $groupby = "{$wpdb->posts}.ID";
    }`
    for this:
    `if ( !empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries ) ) {
    //$groupby = "{$wpdb->posts}.ID";
    }`

    I think it's a bug in Wordpress, I hope that with this change, do not spoil other things ..: S

    Posted 4 years ago #
  22. I know this in an old post but it is still relevant to me.

    I have client that uses blog posts to review books as well as news items and general blog posts.

    I want the book review list to be sorted alphabetically, but the other post types to be sorted in desc date order.

    How can I do that?

    Thanks in advance

    Posted 3 years ago #
  23. Elliott
    Support

    Try this out, https://wordpress.org/plugins/post-types-order/.

    Posted 3 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme