FacetWP – show ghost posts

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

add_filter( ‘facetwp_pre_filtered_post_ids’, ‘store_pre_filtered_post_ids’ );
add_filter( ‘facetwp_filtered_post_ids’, ‘store_filtered_post_ids’ );

function store_pre_filtered_post_ids( $post_ids ) {
$GLOBALS[‘unfiltered_ids’] = $post_ids;
return $post_ids;
}

function store_filtered_post_ids( $post_ids ) {
$GLOBALS[‘filtered_ids’] = $post_ids;

if ( isset( $GLOBALS[‘unfiltered_ids’] ) ) {
return $GLOBALS[‘unfiltered_ids’];
}
return $post_ids;
}

{{/gist}}{{gist file=”your-template.php” lang=”php”}}
<?php $filtered_ids = isset( $GLOBALS[‘filtered_ids’] ) ? $GLOBALS[‘filtered_ids’] : array(); ?>

<?php while ( have_posts() ): the_post(); ?>
<?php $classname = in_array( get_the_ID(), $filtered_ids ) ? ” : ‘ghost’; ?>
<p class=”<?php echo $classname; ?>”>
<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>
</p>
<?php endwhile; ?>
{{/gist}}