I am using the acf wordpress plugin to add a boolean field (featured_project) to a custom post(project).
I am trying to sort the posts on the category archive page, to show the posts that are featured at the top and non featured at the bottom.
There are multiple categories with the same type of post.
I have read some other similar problems where the solutions were to use 'wp_query' or pre_get_posts but I can't seem to get it to work.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if ( get_field('featured_project') ) { ?>
<article class='project featured' id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article">
<a href='<?php the_permalink(); ?>'>
<h3 class="h2"><?php the_title(); ?></h3>
<?php
$url = wp_get_attachment_url( get_post_thumbnail_id() );
$width = 300;
$height = 200;
$crop = true;
$retina = false;
// Call the resizing function (returns an array)
$image = matthewruddy_image_resize( $url, $width, $height, $crop, $retina );
?>
<img src='<?php echo $image['url']; ?>'/ alt='<?php the_title(); ?>'>
</a>
<?php // the_post_thumbnail( 'projects-full', false ); ?>
<div class='excerpt'><?php the_excerpt(); ?></div>
</article>
<?php } else { ?>
is part of the code in the category file.
Thanks
Update: Still haven't found a solution, can anyone else chime in?
if
statement is working is what I am saying, you wanted get_field... to return true or 1, does it give you that? – dojs