Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   [SOLVED] Sorting by modification date (http://forum.bytesforall.com/showthread.php?t=19642)

arteny Feb 16, 2013 05:37 AM

[SOLVED] Sorting by modification date
 
How to do it?
I can do it adding
if( have_posts() ) :
// begin of my code >>
if (is_main_query()) :
query_posts($query_string.'orderby=modified');
endif;
// << end of my code
into begin of bfa_loop function (montezuma/includes/template_tags.php file)
but in this case all posts are shown each time not depend on if I select some tag or category. in correct order, but I don't need them all in those cases.

lmilesw Feb 16, 2013 07:39 AM

I would use the List Category Posts plugin.

arteny Feb 16, 2013 11:55 AM

Quote:

Originally Posted by lmilesw (Post 96595)
I would use the List Category Posts plugin.

lmilesw, I installed it, but didn't understand how to use it. I got that I should write
[catlist categorypage="yes" orderby=modified]
But where should I put this pseudo-code?

juggledad Feb 16, 2013 12:11 PM

you put shortcodes in posts or pages

arteny Feb 16, 2013 12:28 PM

In this case this plugin nothing helps me.
If I put this pseudo-code in post or page it really show me list of links to posts with correct order here.
So I can do separate page which can show posts (excerpts are possible as well) with needed conditions.
But I don't need this list. I want to keep current standard behavior of index page - when I can click on tag or on category and it shows filtered posts. Only I need posts previews are sorted by modified date.

juggledad Feb 16, 2013 01:04 PM

you could try making a child theme and using the is_main_query function to change the main query.

lmilesw Feb 16, 2013 02:47 PM

You can add the necessary attributes to the shortcode to show full posts, excerpts, images, etc. It might take a bit to understand completely how it works but I believe it will do what you want.

jerryc Feb 16, 2013 03:31 PM

If you can do it with php, you might be able to use the technique shown in this post.

arteny Feb 17, 2013 02:16 AM

I found the solution:
use this snippet:

Code:

function order_posts_by_mod_date($orderby) {
  if  (is_home() || is_archive() || is_feed()) {
    $orderby = "post_modified_gmt DESC";
  }

  return $orderby;
}

add_filter('posts_orderby', 'order_posts_by_mod_date', 999);

just dump this snippet into functions.php


All times are GMT -6. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.