Support

Account

Home Forums Backend Issues (wp-admin) Show posts previously marked true on home edit page

Unread

Show posts previously marked true on home edit page

  • Hiya! I’m creating a site with a home page that only shows selected posts on the home page which have been previously marked with an ACF pro true/false button

    I can get only these posts to show on the home with the following code:

    <?php
    	$args = array(
    		'post_type' => array( 'post', 'entrevistas', 'articulos', 'casos_de_exito' ),
    		'posts_per_page' => -1,
    		'meta_query' => array(
    			array(
    				'key' => 'mostrar_en_la_home',
    				'value' => '1',
    				'compare' => '==' // not really needed, this is the default
    			)
    		)
    	);
    	$the_query = new WP_Query($args);
    	if ($the_query->have_posts()) {
    
    	?>
    		<ul class="grid-container">
    			<?php
    			while ($the_query->have_posts()) {
    				$the_query->the_post();
    
    				if( get_post_type() == 'entrevistas' ) {
    
    					get_template_part ( 'template-parts/content', 'interview' );
    
    				} elseif( get_post_type() == 'casos_de_exito' ) {
    
    					get_template_part ( 'template-parts/content', 'success' );
    
    				} elseif( get_post_type() == 'articulos' ) {
    
    					get_template_part ( 'template-parts/content', 'article' );
    
    				} else {
    
    					get_template_part ( 'template-parts/content', 'news' );
    
    				}
    
    			} // end while have posts
    			?>
    		</ul>
    	<?php
    		wp_reset_postdata();
    	} // end if have posts
    ?>

    but I would like to create a home page template where the user can assign each post or post-type to a certain position on the page (I’m using CSS grid to lay the site out)

    So for example, I would like to create a repeater with maybe a Page Link field which only shows the posts that have been previously marked as ‘Show on home’

    Is this possible or is there another way to do this?
    I’m afraid I’m just a front end designer who messes with a little PHP when I need to manipulate stuff…

    Thanks for a great plugin, and for any help in advance,

    Gerard

Viewing 1 post (of 1 total)

The topic ‘Show posts previously marked true on home edit page’ is closed to new replies.