WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field Template
Sorting a listing of "Child Pages" using their custom feilds (1 post)

  1. kennyalancramer
    Member
    Posted 1 year ago #

    I am creating a schedule listing for our festival website (http://www.HotRibsCoolJazz.org)... Basically, I am creating "Artist Information" pages for each performer... each of these "Artist Information" pages has special custom fields (for the stage, start time, day, etc.)... These pages are "child pages" of the parent "Line-up Page"... Here is my code on the Line-Up Page template... How can I change the $querystr to sort by one of the custom fields on these artist pages...

    <?php
    					$current_page = $post->ID;
    					$querystr = "
    						SELECT * from $wpdb->posts
    						WHERE post_type = 'page'
    						AND post_parent = $current_page
    						ORDER BY menu_order ASC
    						";
    
    					$child_pages = $wpdb->get_results($querystr, OBJECT);
    					if ($child_pages):
    					foreach($child_pages as $post) :
    					setup_postdata($post); ?>
                                		<?php the_title(); ?>
                                        <?php
    									/** Get the "Stage" custom field */
    									$stage = get_custom_field('Stage');
    									if( $stage ) {
    									?>
                                        <br/>
    									<?php echo $stage; ?>
    									<?php } ?>
                                        <?php
    									/** Get the "Start-Hour" custom field */
    									$startHour = get_custom_field('Start-Hour');
    									if( $startHour ) {
    									?>
                                        <br/>
    									<?php echo $startHour; ?>
    									<?php } ?>
                                        <br/>
    
    					<?php endforeach; ?>
    					<?php else : ?>
    					No additional information about activities is currently available.  Check back soon!
    					<?php endif; ?>
    					<?php rewind_posts(); ?>

    Here is my Template Content from the Custom Field Template settings:

    [Artist]
    type = textfield
    size = 35
    
    [Stage]
    type = select
    value = American Electric Power Stage presented by ABC 6 # North Bank Park Stage presented by FOX 28 # Jazz Café
    default = none
    
    [Day]
    type = select
    value = Friday # Saturday # Sunday
    default = none
    
    [Start-Time]
    type = fieldset_open
    legend = Start Time
    
    [Start-Hour]
    type = textfield
    size = 2
    
    [Start-Minutes]
    type = textfield
    size = 2
    label = :
    
    [Start-Morning-Afternoon]
    type = radio
    value = AM # PM
    default = AM
    
    [Start-Time1]
    type = fieldset_close 
    
    [End-Time]
    type = fieldset_open
    legend = End Time
    
    [End-Hour]
    type = textfield
    size = 2
    
    [End-Minutes]
    type = textfield
    size = 2
    label = :
    
    [End-Morning-Afternoon]
    type = radio
    value = AM # PM
    default = AM
    
    [End-Time1]
    type = fieldset_close

    Since the plugin doesn't support "hh:mm" time information, I am going to sort by Start-Morning-Afternoon, then by Start-Hour, and the by Start-Minutes.

    Please help :) Thanks!!

    http://wordpress.org/extend/plugins/custom-field-template/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by kennyalancramer
  • This topic is not resolved
  • WordPress version: 3.4.2