Support

Account

Home Forums General Issues Custom Post Type as WordPress Front/Home Reply To: Custom Post Type as WordPress Front/Home

  • OK, happy days. I found this handy little snippet. I applied it, changed out the values with mine and added it to my functions.php file.

    
    	// populate acf field (select_post) with post types (clients)
    
    	function acf_load_select_post( $field ) {
    		$field['choices'] = get_post_type_values( 'clients' );
    		return $field;
    	}
    	add_filter( 'acf/load_field/name=select_post', 'acf_load_select_post' );
    
    	function get_post_type_values( $post_type ) {
    		$values = array();
    		$defaults = array(
    			'post_type' => $post_type,
    			'post_status' => 'publish',
    			'posts_per_page' => -1,
    			'orderby' => 'title',
    			'order' => 'ASC'
    		);
    		$query = new WP_Query( $defaults );
    		if ( $query->found_posts > 0 ) {
    			foreach ( $query->posts as $post ) {
    				$values[get_the_title( $post->ID )] = get_the_title( $post->ID );
    			}
    		}
    		return $values;
    	}
    

    This populates the Select field on the page called Home. Huzzah!

    Now I just need to create my home page template to populate the page with the content of the selection. That would be the index.php file, right?