Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* The template for displaying search results pages.
*
* @package _s
*/
get_header(); ?>
<div id="primary" class="contents-search-results">
@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
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 / 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
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;
}
<?php
/**
* Template Name: Newsroom
*
* @package becketfund
*/
global $post;
// retrieve our search query if applicable .
<?php
/**
* The default template for displaying content
*
* Used for both single and index/archive/search
*
* @package Catch Themes
* @subpackage Clean Journal
* @since Clean Journal 0.1
*/
<?php
/**
* Template Name: search-events-nodates
*
* This is template will display a login form
*/
add_action('get_header', 'ck_do_login_form');
// Début de page pour supprimer les commentaires présents sur les pages par défault
<?php
if (!is_user_logged_in()) {
if (!in_array($GLOBALS['pagenow'], array('wp-login.php'))) {
if ( isset( $_REQUEST['swpnonce'] ) || isset( $_REQUEST['swppurge'] ) ) {
//Indexer
} else {
$actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if ( wp_redirect(wp_login_url($actual_link)) ) {
exit;
<?php
// Seach WP posts per page
add_filter('searchwp_posts_per_page', function($posts_per_page, $engine, $terms, $page) {
return 20;
}, 99, 4);