Skip to content

Instantly share code, notes, and snippets.

Jon Christopher jchristopher

Block or report user

Report or block jchristopher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9350747
$attachments = new Attachments( 'attachments' ); // 'attachments' is your instance name
if( $attachments->exist() ) : ?>
<?php while( $attachments->get() ) : ?>
Attachments data to go here
<?php endwhile; ?>
<?php endif; ?>
jchristopher / gist:9667991
Created Mar 20, 2014
Use SearchWP's Term Highlight extension to grab an excerpt from anywhere it can (e.g. if no matches are in the actual excerpt, expand the search to string-based Custom Fields)
View gist:9667991
/* SearchWP Term Highlight offers an alternative to the_excerpt()
If you're looking to generate any sort of excerpt based on one of the following:
- the actual excerpt
- the generated excerpt from the post content
- the post content itself
- string-based custom field values
this function is for you. It will try to find one of the above (in that order)
and output something with at least one search term in it (if possible)
jchristopher / gist:9672109
Last active Aug 29, 2015
A sample implementation of a SearchWP search form and corresponding results loop using the Shortcodes extension
View gist:9672109
<h3>Search Form</h3>
[searchwp_search_form engine="my_test_engine" target="" var="searchvar" button_text="Find Results"]
<div class="search-results-wrapper">
[searchwp_search_results engine="my_test_engine" var="searchvar" posts_per_page=2]
<h2>[searchwp_search_result_link direct="true"]</h2>
View gist:9793116
// use my_search_engine instead of the default search engine when performing
// Job Listing searches in WP Job Manager
function my_searchwp_wpjmi_job_engine() {
return 'my_search_engine';
add_filter( 'searchwp_wpjmi_job_engine', 'my_searchwp_wpjmi_job_engine' );
View gist:9793149
// force SearchWP configuration to override WP Job Manager's when performing a Job Listing search
add_filter( 'searchwp_wpjmi_job_post_type_override', '__return_true' );
View gist:9793172
// disable SearchWP integration with WP Job Manager Resume searches
add_filter( 'searchwp_wpjmi_hijack_resume_search', '__return_false' );
View gist:9793187
// use my_other_search_engine instead of the default search engine when performing
// Resume searches in WP Job Manager
function my_searchwp_wpjmi_resume_engine() {
return 'my_other_search_engine';
add_filter( 'searchwp_wpjmi_resume_engine', 'my_searchwp_wpjmi_resume_engine' );
View gist:9793202
// force SearchWP configuration to override WP Job Manager's when performing a Job Listing search
add_filter( 'searchwp_wpjmi_resume_post_type_override', '__return_true' );
jchristopher / gist:9806867
Created Mar 27, 2014
Integrate SearchWP and Nexus ElegantTheme
View gist:9806867
// This code is ideally added to a child theme's functions.php
// OR
// at the *bottom* of the main theme's functions.php
// (do not forget to remove the opening <?php tag from this gist)
if( is_search() && class_exists( 'SearchWP' ) ) {
// remove the troublesome theme filter
remove_action( 'pre_get_posts', 'et_custom_posts_per_page' );
View gist:9907436
if( class_exists( 'SearchWP_Term_Highlight' ) ) {
// instantiate the highlighter
$searchwp_highlighter = new SearchWP_Term_Highlight();
// decipher the search query (NOTE: update the GET var if necessary)
$search_query = '';
if( isset( $_GET['swpquery'] ) && ! empty( $_GET['swpquery'] ) ) {
$search_query = sanitize_text_field( urldecode( $_GET['swpquery'] ) );
You can’t perform that action at this time.