Can’t save custom post type fields

Try debug add_action(‘save_post’, ‘add_fields_contest’, 10, 2 ); function add_fields_contest( $id, $post ) { require_once(ABSPATH . ‘wp-includes/pluggable.php’); if ( $post->post_type == ‘contest’ ) { update_post_meta( $id, ‘userid’, $_POST[‘userid’] ); update_post_meta( $id, ‘title’, $_POST[‘title’] ); update_post_meta( $id, ‘name’, $_POST[‘name’] ); update_post_meta( $id, ‘age’, $_POST[‘age’] ); echo ‘Saving data to post id: ‘.$id; var_dump($_POST); die(); } I will … Read more

Custom post status

Have you read Custom Status on codex.wordpress.org/Post_Status? NOTICE: This function does NOT add the registered post status to the admin panel. This functionality is pending future development. Please refer to Trac Ticket #12706. Consider the action hook post_submitbox_misc_actions for adding this parameter. Adding a custom status to WordPress is done via the register_post_status() function. This … Read more

Display a Custom Post Type within another with hierarchically slug

Base on comment, you need to create a little function to display these related posts. You can do it in different ways, here is an simple example by adding your own action to the template. in your template file place where you want to show related lessons do_action(‘related_lesson’); In functions.php function get_related_lesson(){ global $post; $args … Read more

Group/list/sort custom post type posts by date in tabs from acf datepicker field

It’s probably best to loop through your posts two times. Once to group them by year and once to print the posts. Something like this: (not tested) $formatted_posts = array(); while ( $subsQuery->have_posts() ) : $subsQuery->the_post(); $year = get_field(‘year’); // add them to formatted_posts array and group by year $formatted_posts[$year][] = $post; endwhile; foreach($formatted_posts as … Read more

Importing URLs of Audio Enclosures

It’s hard to tell what you’re working with from the image, but I’ll assume newline breaks. <?php $string = “http://www.podcast.com/track.mp3 2207703 audio/mpeg”; echo “<pre>”; echo $string; // should show multiple rows To grab the first line, try preg_match: // now grab the first line if( preg_match (‘/^(.*)$/m’, $string, $matches) ){ echo $matches[0]; // first line … Read more

Display all posts from single taxonomy term

You have a problem with the tax_query arrays array( ‘post_type’ => ‘attorneys’, ‘tax_query’ => array( ‘taxonomy’ => ‘practice-areas’, ‘field’ => ‘slug’, ‘terms’ => ‘appeals’, ) ) The tax_query parameter in $loop must look like this: $loop = new WP_Query( array( ‘post_type’ => ‘attorneys’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘practice-areas’, ‘field’ => ‘term_id’, ‘terms’ => … Read more

SQL LIKE in WP_Query

Maybe a simple typo in, if ( $wp_enchanced_title_search = $wp_query->get( ‘wp_enchanced_title_search’ ) this can never fire, you should put == instead = if ( $wp_enchanced_title_search == $wp_query->get( ‘wp_enchanced_title_search’ ) Hope it works !

WordPress loop multiple orderby query with Types toolset

if you created the custom field using wp-Type then you would have to use wpcf-state-code $state_code = types_render_field(“state-code”, array()); $args = array( ‘post_type’ => ‘store’, ‘posts_per_page’ => 100, ‘orderby’ => array( ‘ASC’ => ‘DESC’, ‘meta_value’ => ‘ASC’ ) ‘meta_key’ => ‘wpcf-state-code’, ); This should work, let me know.