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
<?php
$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
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
<?php
/* 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)
View gist:9793116
<?php
// 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
<?php
// 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
<?php
// disable SearchWP integration with WP Job Manager Resume searches
add_filter( 'searchwp_wpjmi_hijack_resume_search', '__return_false' );
View gist:9793187
<?php
// 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
<?php
// 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
jchristopher / gist:9806867
Created Mar 27, 2014
Integrate SearchWP and Nexus ElegantTheme
View gist:9806867
<?php
// 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
<?php
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'] ) );
@jchristopher
jchristopher / gist:9925992
Created Apr 2, 2014
Enable matching any word within a taxonomy term in the Term Archive Priority SearchWP extension
View gist:9925992
<?php
add_filter( 'searchwp_tax_term_or_logic', '__return_true' );
You can’t perform that action at this time.