WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields Creator
Accessing repeated custom fields (1 post)

  1. yoxalld
    Member
    Posted 1 year ago #

    Hi, first off, great job with WCK, they make adding custom post types and custom fields really easy!

    I have created a custom field box for specials. For each special you have: type of special, name of special, price, and day of the week.

    What I need to do is check to see if there is a special of a certain type (Drink) and if there is echo the other info for the special. But I can't seem to figure out how to access the next dimensional array to check each key value pair. I am not great at dealing with multidimensional arrays apparently.

    Here is what I have so far:

    $args = array(
    	'post_type' => 'business',
    	'meta_key' => 'specials'
    	);
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); 
    
    $specials = get_post_meta( $post->ID, 'specials');
    	foreach( $specials as $special){
    		if ($special ['type-of-special'] == 'Drink' ) {
    
    			echo $special ['name-of-special'];
    		}
    
    	} 
    
    endwhile;

    I created the custom post type of business and added the custom fields to that post type. Any help would be greatly appreciated! Let me know if you need any other information from me. Thanks!

    http://wordpress.org/extend/plugins/custom-fields-creator/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic