Preventing Truncation of First Post

By truncating, do you mean using the_excerpt() rather than the_content()? Or do you mean using the_content() with <!–more–> tags ?. In either case, you can alter how a post behaves by using the following: <?php if (have_posts()) : while (have_posts()) : the_post(); //We check that we are this is the first post in the loop … Read more

Function to allow single post template based on custom taxonomy?

I think what you’re looking for is the WordPress Template Hierarchy. Basically you can just name the template single-{custom-post-slug}.php and put it in the right directory. Update Now that I understand what you’re actually asking: I bet you could hook {$type}_template, which is called by get_query_template(). It’s expecting a path to the template which has … Read more

Random Custom Post Type Titles

WP_Query has an orderby property which can be set to rand. If you change your query string to ‘post_type=announcements&posts_per_page=5&orderby=rand’ you should be good to go. You might want to take the time to read through the whole documentation for WP_Query, just so you’re familiar with its capabilities.

How do I list a custom field and custom taxonomies for each result in a loop?

You can get custom field values with get_post_meta. Like so… <?php $wp_query = new WP_Query(); $wp_query->query(‘post_type=customtype&showposts=10′.’&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); the_title(); // <- works if( $some_meta = get_post_meta( get_the_ID(), ‘the_meta_key_you_want’, true ) { // you could put other formatting here. echo $some_meta; } endwhile; You’ll need to change the_meta_key_you_want in the call to get_post_meta, of … Read more

Custom MetaBox : Food Menu Item Available Dates

If you have created you custom post type you can add the metabox like this: add_action( ‘add_meta_boxes’, ‘add_dates’ ); function add_dates() { add_meta_box(‘date_select’, ‘Dates’, ‘date_select’, ‘customposttype’, ‘side’, ‘default’); } function date_select() { global $post; echo ‘<input type=”hidden” name=”date_select_meta_noncename” id=”date_select_meta_noncename” value=”‘ . wp_create_nonce( plugin_basename(__FILE__) ) . ‘” />’; $gender = get_post_meta($post->ID, ‘_date’, true); // Insert checkboxes … Read more

Single parent post lists child posts with pagination

Something like this should do the trick for ordering by title, and using pagination: global $wp_rewrite, $wp_query; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <header class=”entry-header”> <h1 class=”entry-title”><?php the_title(); ?></h1> </header><!– .entry-header –> <?php //If top level, find children if($post->post_parent == 0): $children = new WP_Query(array( ‘post_type’=>’page’, ‘post_parent’=>$post->ID, ‘paged’ => … Read more

Get_the_term_list inexplicably adds values in foreach

The problem lies with the get_the_term_list() function, which is defined with the following arguments: get_the_term_list( $id = 0, $taxonomy, $before=””, $sep = ”, $after=”” ) You’re defining the $before argument as true which PHP prints as 1 so that’s why it’s printing a 1 before the list. You should either remove the argument altogether: get_the_term_list( … Read more