• I am using WP as a CMS and I’m trying to figure out the best and easiest way to arrange post inside of a category. I know I can just change the dates but then that changes my “newest post” list.
    I was wondering if there is a way to drag and drop the post like you can with several plugins for page order?
    What I doing this for is, I have a list of albums and I would like to have them listed in order by year. The problem is that when I get a new album that fits in between two albums already posted. I want to be able to put the new album in the correct order in my post order but I want the new post to retain the current post date so that it will still be listed as my most resent addition.

    If anyone can please help me I would greatly appreciate it.

Viewing 8 replies - 16 through 23 (of 23 total)
  • Hi nzde

    Here’s mine
    My category number was 5 so I created a new template called category-5.php so you have to call it category-4.php and this is the complete code with your variables

    <?php get_header(); ?><?php get_sidebar(); ?>
    <div id="wrapper">
    
    	<div class="mission">
    
    	<?php
    
            if((function_exists('ls_getinfo')) && (ls_getinfo('isref'))) { ?>
    <h2><?php ls_getinfo('terms'); ?></h2>
    
    p>You came here from <?php ls_getinfo(‘referrer’); ?> searching for <i><?php ls_getinfo(‘terms’); ?></i>. These posts might be of interest:</p>
    <ul>
    <?php ls_related(5, 10, '<li>', '</li>', '', '', false, false); ?>
    </ul>
      <?php }   else { ?>
    <?php } ?></div>
            <div id="content">
    <?php
    
    $querystr = "
    SELECT * FROM $wpdb->posts
    LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
    LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
    LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    WHERE $wpdb->term_taxonomy.term_id = 4
    AND $wpdb->term_taxonomy.taxonomy = 'category'
    AND $wpdb->posts.post_status = 'publish'
    AND $wpdb->postmeta.meta_key = 'Event_date'
    ORDER BY $wpdb->postmeta.meta_value ASC
    ";
    
     $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    ?>
     <?php if ($pageposts): ?>
      <?php foreach ($pageposts as $post): ?>
        <?php setup_postdata($post); ?>
    
        <div class="post" id="post-<?php the_ID(); ?>">
          <h2><?php the_title(); ?></h2>
                <div class="entry">
             <?php the_content('Read the rest of this entry ?'); ?>
          </div>
    
        </div><hr />
      <?php endforeach; ?>
    
      <?php else : ?>
        <h2 class="center">Not Found</h2>
        <p class="center">Sorry, but you are looking for something that isn't here.</p>
    
     <?php endif; ?>
            </div>
    </div>
    <?php get_footer(); ?>

    Many thanks baalam. Really appreciate it; extremely helpful.

    The only problem I’m left with concerns the method of date input I’m using for the custom field. I’m currently requiring dates to be entered in the format mm-dd-yyyy, but the above code won’t order the output dates chronologically. This rough, demo output list shows you what I mean:

    event 01-31-2009- 18 June 2008 – 0 comments
    event 06-20-2008- 18 June 2008 – 0 comments
    event 08-15-2008- 18 June 2008 – 0 comments
    event 10-21-2010- 18 June 2008 – 0 comments
    event 12-01-2008- 18 June 2008 – 0 comments

    The seemingly obvious reason is that the system is only reading the first two digits, and ordering by reference to those.

    Can anyone help me please with what sort of date input structure I should use (for my custom text field) to make the output chronologically ordered when using the code above?

    Many thanks for your help.
    Richard

    I have to give a special value

    001 will be the event I want at the top of the page
    The second one I gave the value 007 so it goes tot he second place and it gives me a range of 6 events to add in between

    I don’t know if I’m clear enough

    here is a querystr im using:


    $querystr = "
    SELECT $wpdb->posts.*
    FROM $wpdb->posts
    LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
    WHERE $wpdb->postmeta.meta_key = 'views'
    AND $wpdb->posts.post_status = 'publish'
    AND $wpdb->posts.post_type = 'post'
    ORDER BY ($wpdb->postmeta.meta_value + 0) DESC LIMIT 3,11;
    ";

    I’d like to add a category condition but dont know how to add it… can anyone tell me please ?

    i’ve tried this:


    $querystr = "
    SELECT $wpdb->posts.*
    FROM $wpdb->posts
    LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
    LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
    LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    WHERE $wpdb->term_taxonomy.term_id = $cat_ida
    AND $wpdb->term_taxonomy.taxonomy = 'category'
    WHERE $wpdb->postmeta.meta_key = 'views'
    AND $wpdb->posts.post_status = 'publish'
    AND $wpdb->posts.post_type = 'post'
    ORDER BY ($wpdb->postmeta.meta_value + 0) DESC LIMIT 3,11;
    ";

    but this doesnt work.. any hint ?

    Hi there – I’ve now got this working by using a custom field entry in which I insert dates using this pattern: yyyy-mm-dd, where 1 July 2008, for example, would be 2008-07-01. This works perfectly in ordering the dates chronologically, with the closest date at the top of the list.

    One question I now have please is whether anyone knows how to insert a bit of code into what balaam really helpful gave us above, to limit the number of posts that appear to a determined number, say the first five?

    Would be very grateful if anyone can assist. I know how to do this with a general post query, e.g.:

    <?php query_posts('showposts=5&cat=4'); ?>

    but that doesn’t seem apt in the code above.

    Can anyone help please?

    fas.khan

    (@faskhan)

    Simple Solution of the originally asked question.

    https://joelstarnes.co.uk/blog/postmash/

    You may wish to check these plugins:
    custom-post-order and postmash

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Arrange Post Order?’ is closed to new replies.