Rose
Forum Replies Created
-
I have 155 published posts. That shouldn’t be too many, should it?
Thanks for trying. This is just so baffling. I wonder if it could be something to do with my theme? I suppose it can’t hurt to test it out in another theme just to see.
<?php /* Template Name: Post Index by Genre */ ?> <?php get_header(); ?> <?php // Use filters to sort a query on terms of a selected taxonomy. // See http://wordpress.mcdspot.com/2010/05/30/filters-to-modify-a-query/ // for the code of the filters used. $taxonomy = 'genre'; $mam_global_join = "JOIN $wpdb->term_relationships tr ON ($wpdb->posts.ID = tr.object_id) JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = '$taxonomy') JOIN $wpdb->terms t ON (tt.term_id = t.term_id)"; $mam_global_fields = ", t.name AS term_name"; $mam_global_orderby = "term_name ASC, $wpdb->posts.post_title ASC"; $args = array( 'posts_per_page' => -1, 'ignore_sticky_posts' => 1, 'post_type' => 'post', ); $q = new WP_Query($args); $mam_global_join = $mam_global_fields = $mam_global_orderby = ''; // Turn off filters print_r('<p>REQUEST:');print_r($q->request);print_r('</p>'); //print_r('<p>POSTS:');print_r($q->posts);print_r('</p>'); if ($q->have_posts()) { $current_term = ''; while ($q->have_posts()) { $q->the_post(); if ($current_term != $post->term_name) { $current_term = $post->term_name; echo "<h2>TERM: $current_term</h2>"; } echo "<p>TERM:$post->term_name $post->post_title</p>"; } } ?> <?php get_footer(); ?>When I change the -1 back to 50, the pring line gives me:
REQUEST:SELECT SQL_CALC_FOUND_ROWS wp_posts.*, t.name AS term_name FROM wp_posts JOIN wp_term_relationships tr ON (wp_posts.ID = tr.object_id) JOIN wp_term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'genre') JOIN wp_terms t ON (tt.term_id = t.term_id) WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY term_name ASC, wp_posts.post_title ASC LIMIT 0, 50I don’t know if that’s helpful.
I uncommented and tried again using -1. I still only get a blank page.
When I use the second example, all I get is a blank page. When I use ‘posts_per_page’ => 50, it works. When I go as high as ‘posts_per_page’ => 100, I get a blank page again.
Anyone know how to call up ALL posts using the above code? This isn’t working:
$args = array( 'numberposts' => -1, 'ignore_sticky_posts' => 1, 'post_type' => 'post', ); $q = new WP_Query($args);Nor is:
$args = array( 'posts_per_page' => -1, 'ignore_sticky_posts' => 1, 'post_type' => 'post', ); $q = new WP_Query($args);That did it, thank you very much! This will save me so much time.
I created a template with the following code:
<?php /* Template Name: Post Index by Genre */ ?> <?php get_header(); ?> <?php // Use filters to sort a query on terms of a selected taxonomy. // See http://wordpress.mcdspot.com/2010/05/30/filters-to-modify-a-query/ // for the code of the filters used. $taxonomy = 'genre'; $mam_global_join = "JOIN $wpdb->term_relationships tr ON ($wpdb->posts.ID = tr.object_id) JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = '$taxonomy') JOIN $wpdb->terms t ON (tt.term_id = t.term_id)"; $mam_global_fields = ", t.name AS term_name"; $mam_global_orderby = "term_name ASC, $wpdb->posts.post_title ASC"; $args = array( 'ignore_sticky_posts' => 1, 'post_type' => 'post', ); $q = new WP_Query($args); $mam_global_join = $mam_global_fields = $mam_global_orderby = ''; // Turn off filters //print_r('<p>REQUEST:');print_r($q->request);print_r('</p>'); //print_r('<p>POSTS:');print_r($q->posts);print_r('</p>'); if ($q->have_posts()) { $current_term = ''; while ($q->have_posts()) { $q->the_post(); if ($current_term != $post->term_name) { $current_term = $post->term_name; echo "<h2>TERM: $current_term</h2>"; } echo "<p>TERM:$post->term_name $post->post_title</p>"; } } ?> <?php get_footer(); ?>All I got was a list of the 10 most recent posts. It didn’t even display the genre at all. Could you tell me what I’m doing wrong?
Thank you! Before I start experimenting with this, will this address both the repetition of code and the orderby issue or just one of the issues? And will this work in a page template?
Forum: Fixing WordPress
In reply to: Modify custom field value before desplaying itYes, that’s pretty much what I want to do. Honestly, I’ll be surprised if there *is* a way to do it, but it never hurts to ask, right? In the meantime, I can use post ids; it’ll just be harder.
Forum: Fixing WordPress
In reply to: Select existing tags when postingI’m afraid that’s waaaaay too much work. I’ve been adding them manually and while the dropdown is helpful, it’s not all that efficient, since each post needs about ten tags. I have 200+ posts to tag. It would be a lot easier to just select the ones I need.
Forum: Plugins
In reply to: [Plugin: JournalPress] Forcing the display of custom fields on crosspostingI managed to add the custom field “Notes” appear by inserting it right before $the_event, like so:
$jdata['event'] = '<p><b>Notes:</b> '.get_post_meta($p->ID, 'Notes', true).'</p>'.$the_event; $jdata['subject'] = apply_filters( 'the_title', $p->post_title );Now my issue is that I can’t seem to figure out how to make an “if” statement, so that the string of text I’ve added before $the_event only appears if the “Notes” custom field actually exists.
Forum: Fixing WordPress
In reply to: Need to delimit/seperate tags with semicolons instead of commasNo, the display can be separated by commas. I mean in the field where you actually type in the tags to add it to a post. The tags need to be able to INCLUDE commas without breaking up into smaller tags.
As far as I know, this is not a theme-specific issue. This is probably a hack of some kind.
Forum: Themes and Templates
In reply to: taxonomy.php not workingP.S. my taxonomy.php file currently looks like this:
<?php get_header(); $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?> <h1 class="page-title"><?php printf( __( 'Posts classified under: %s', 'supernatural' ), '<span>' . $term_name . '</span>' ); ?></h1> <?php if ('' != $term_descr ) { echo "<p>$term_descr</p>\n"; } ?> <?php get_footer(); ?>