Skip to content

Instantly share code, notes, and snippets.

<?php
function my_searchwp_omit_meta_key( $omit, $meta_key, $the_post ) {
$url_meta = 'link-url';
$url_found = strpos( $meta_key, $url_meta );
// if "link-url" is in a custom field meta key name, do not index it
if ( false !== $url_found ) {
$omit = true;
}
@jchristopher
jchristopher / swp-query.php
Last active September 14, 2016 19:10 — forked from anonymous/swp-query.php
SearchWP query
<?php
// retrieve search variables from url
foreach ( $_GET as $key => $value ) {
$$key = sanitize_text_field( $value );
}
// retrieve our search query if applicable
$query = isset( $_REQUEST['swpquery'] ) ? sanitize_text_field( $_REQUEST['swpquery'] ) : '';
// retrieve our pagination if applicable
$swppg = isset( $_REQUEST['swppg'] ) ? absint( $_REQUEST['swppg'] ) : 1;
<?php
session_start();
/* Template Name: SearchWP State Search Results */
global $post;
//get the query
$query = isset( $_REQUEST['t'] ) ? sanitize_text_field( $_REQUEST['t'] ) : '';
$stateId = isset($_REQUEST['stateId']) ? sanitize_text_field( $_REQUEST['stateId'] ) : '';
if($stateId == '*') {
$stateId = false;
@jchristopher
jchristopher / functions.php
Created March 7, 2016 14:38
alas, the mess that is my functions.php
<?php
/**
* SimpleTruth2.0 functions and definitions.
*
* This file will be cleaned up before live as there are various unneeded calls.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package SimpleTruth2.0
*/
<?php
/**
* The template for displaying search results pages.
*
* @package _s
*/
get_header(); ?>
<div id="primary" class="contents-search-results">
<?php
// Add to your theme's functions.php
add_filter( 'searchwp_indexed_post_types', 'my_searchwp_indexed_post_types' );
add_filter( 'searchwp_engine_settings_default', 'my_searchwp_engine_settings_default', 10, 2 );
function my_searchwp_indexed_post_types( $post_types ) {
if ( ! in_array( 'attachment', $post_types ) ) {
$post_types[] = 'attachment';
}
[2015-20-05 6:30:11][notice][555cc4a378e56]
[2015-20-05 6:30:11][notice][555cc4a378e56] ========== INIT 555cc4a378e56 2.5.4 ==========
[2015-20-05 6:30:11][notice][555cc4a378e56]
[2015-20-05 6:30:11][notice][555cc4a378e56] checkForMainQuery(): It is the main query
[2015-20-05 6:30:11][notice][555cc4a378e56]
[2015-20-05 6:30:11][notice][555cc4a378e56] ========== END 555cc4a378e56 ==========
[2015-20-05 6:30:11][notice][555cc4a378e56]
[2015-20-05 6:30:12][notice][555cc4a482e1d]
[2015-20-05 6:30:12][notice][555cc4a482e1d] ========== INIT 555cc4a482e1d 2.5.4 ==========
<?php
/**
* The template used for generating blog template Format 1 List
*
* @package WordPress
* @subpackage ASI Themes
* @since IOA Framework V1
*/
<?php
/* Template Name: SearchWP Supplemental Search Engine Postcode Search */
global $post;
// retrieve our search query if applicable
$query = isset( $_REQUEST['postcode'] ) ? sanitize_text_field( $_REQUEST['postcode'] ) : '';
// if there was a space in the search, grab the first part
@jchristopher
jchristopher / Moomin
Last active August 29, 2015 14:07 — forked from anonymous/Moomin
<?php
function my_searchwp_extra_metadata( $extra_meta, $post_being_indexed ) {
// index the author country
$author_country = get_field('my_countries', $post_being_indexed->post_author );
// it's stored as an array so let's get the actual text
$author_country = is_array( $author_country ) && count( $author_country ) ? implode( ' ', $author_country ) : '';
if ( ! empty ( $author_country ) ) {
$extra_meta['my_author_meta_country'] = $author_country;