Pages - Menu

Saturday, 21 February 2015

Request to the server according to custom fields and a post-type

Just a moment, or we need to invoke Article according to custom fields. Ex .: Call all that is blue and small in there.

The first step is to create a post type and then install ACF Advanced Custom Field. Types does too, but experience ACF is Simpler to manage.

 




Consequently we will create custom fields for our Post Type.




<?php
    query_posts(array(
        'post_type' => 'evenement',
        'cat'      => 2, // La catégorie visée
        'meta_query' => array(
                array(
                    'key' => 'date', // Le champ personnalisé
                    'value' => '"19"', // La valeur désiré
                    'compare' => 'LIKE', //
       
                )
            )
    ) ); 
?>
<?php while (have_posts()) : the_post(); ?>
        <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?></li>