Query latest 5 documents?
-
Below is my code that I am trying to query 5 of the most recent documents in buddypress docs, I’ve had no luck using <?php query_posts(‘order=DESC&showposts=5’); ?>
where ‘order=desc’ changes nothing. Can anyone advise?<?php //beginning ?> <h1> Recently uploaded lesson plans</h1> <table class="doctable"> <thead> <tr valign="bottom"> <th scope="column" class="title-cell">Lesson Plan</th> <th scope="column" class="author-cell">Author</th> <th scope="column" class="grade-cell">Grade(s)</th> <th scope="column" class="subject-cell">Subject(s)</th> </tr> </thead> <tbody> <?php //////////////// order not working, looking to show the most recent documents ////////?> <?php query_posts('order=DESC&showposts=5'); ?> <?php while ( bp_docs_has_docs() ) : bp_docs_the_doc() ?> <tr<?php bp_docs_doc_row_classes(); ?>> <?php global $bp; $tax_name = $bp->bp_docs->docs_tag_tax_name; $tags = get_the_terms(get_the_ID(), $tax_name); $tag_names = array('posts_per_page' => 6,); foreach ( $tags as $tag ) { $tag_names[] = $tag->name; } //Get options from database global $wpdb; $tablename = $wpdb->prefix . "tags"; $sql = $wpdb->prepare( "SELECT * FROM $tablename WHERE ID = %d", 1); $results = $wpdb->get_row( $sql, ARRAY_A ); $subject_string = $results["Subject"]; $subjects = explode(",",$subject_string); $grade_string = $results["Grade"]; $grades = explode(",",$grade_string); ?> <td class="title-cell"> <a href="<?php bp_docs_doc_link() ?>"><?php the_title() ?></a> <?php bp_docs_doc_trash_notice(); ?> <?php if ( bp_docs_get_excerpt_length() ) : if (strlen(get_the_excerpt()) > 200) { echo '<p>' . get_excerpt() . ' [...]</p>'; } else { echo '<p>' . get_excerpt() . '</p>'; } endif ?> </td> <td class="author-cell"> <a href="<?php echo bp_core_get_user_domain( get_the_author_meta( 'ID' ) ) ?>" title="<?php echo bp_core_get_user_displayname( get_the_author_meta( 'ID' ) ) ?>"><?php echo bp_core_get_user_displayname( get_the_author_meta( 'ID' ) ) ?></a> </td> <!--<td class="date-cell created-date-cell"> <?php echo get_the_date() ?> </td>--> <td class="grade-cell"> <?php foreach ($tag_names as $name) { if (in_array($name, $grades)) { echo $name.'<br>'; } } ?> </td> <td class="subject-cell"> <?php foreach ( $tag_names as $name) { if (in_array($name, $subjects)) { echo $name.'<br>'; } } ?> </td> <!--<?php do_action( 'bp_docs_loop_additional_td' ) ?>--> </tr> <?php endwhile ?> </tbody> </table> <?php wp_reset_postdata();?> <?php //end of lesson plans ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Query latest 5 documents?’ is closed to new replies.