Skip to content

Instantly share code, notes, and snippets.

@richerimage
Created November 27, 2018 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richerimage/38aa5a4fed97e926a1ef847df8075893 to your computer and use it in GitHub Desktop.
Save richerimage/38aa5a4fed97e926a1ef847df8075893 to your computer and use it in GitHub Desktop.
Facet Test
<?php
add_action( 'wp_head', 'cvl_add_facetwp_fwp_http', 100 );
function cvl_add_facetwp_fwp_http() {
if (is_singular('job_listing')) {
global $post; ?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
FWP_HTTP.post_id = '<?php echo $post->ID; ?>';
});
})(jQuery);
</script>
<?php }
}
add_filter( 'facetwp_query_args', function( $query_args, $class ) {
// $parent = get_the_ID();
$parent = ( !empty( get_the_ID() ) ) ? get_the_ID() : (int) $this->http_params['post_id'];
if ( 'example' == $class->ajax_params['template'] ) {
$query_args['post_parent'] = $parent;
$query_args['post_type'] = 'job_application';
$query_args['post_status'] = 'published';
$query_args['posts_per_page'] = '10';
}
return $query_args;
}, 10, 2 );
?>
Follwing is the error messahe refering to line 25 in this gist
<br />
<b>Fatal error</b>: Uncaught Error: Using $this when not in object context in /home/thesisdn/cvl.stemcell.zone/wp-content/plugins/cvl-functions/inc/cvl-facetwp/cvl-facetwp.php:138
Stack trace:
#0 /home/thesisdn/cvl.stemcell.zone/wp-includes/class-wp-hook.php(286): {closure}(Array, Object(FacetWP_Renderer))
#1 /home/thesisdn/cvl.stemcell.zone/wp-includes/plugin.php(203): WP_Hook-&gt;apply_filters(Array, Array)
#2 /home/thesisdn/cvl.stemcell.zone/wp-content/plugins/facetwp/includes/class-renderer.php(122): apply_filters('facetwp_query_a...', Array, Object(FacetWP_Renderer))
#3 /home/thesisdn/cvl.stemcell.zone/wp-content/plugins/facetwp/includes/class-ajax.php(394): FacetWP_Renderer-&gt;render(Array)
#4 /home/thesisdn/cvl.stemcell.zone/wp-includes/class-wp-hook.php(286): FacetWP_Ajax-&gt;refresh('')
#5 /home/thesisdn/cvl.stemcell.zone/wp-includes/class-wp-hook.php(310): WP_Hook-&gt;apply_filters('', Array)
#6 /home/thesisdn/cvl.stemcell.zone/wp-includes/plugin.php(453): WP_Hook-&gt;do_action(Array)
#7 /home/thesisdn/cvl.stemcell.zone/wp-content/p in <b>/home/thesisdn/cvl.stemcell.zone/wp-content/plugins/cvl-functions/inc/cvl-facetwp/cvl-facetwp.php</b> on line <b>138</b><br />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment