Skip to content

Instantly share code, notes, and snippets.

@ajaydsouza
ajaydsouza / crp-same-post-type.php
Created March 28, 2016 16:25
CRP - Limit to same post type
<?php
/**
* Filter the post types to limit it to the same post type.
*
* @param array $post_types Array of post types included in WHERE clause
* @return array Updated array of post types
*/
function crp_same_post_type( $post_types ) {
global $post;
@ajaydsouza
ajaydsouza / bsearch-examples.php
Created December 26, 2015 21:06
Examples of using various filters in Better Search WordPress plugin
<?php
/**
* Filter to override the censor character in Better Search.
*
* @param string Default censor string
*
* @return string Censored string
*/
function filter_bsearch_censor_char( $censorChar ) {
return "*";
@ajaydsouza
ajaydsouza / same-language.php
Last active September 26, 2015 00:34
CRP / Top 10 - WPML functions
<?php
/**
* This function forces all related / top ten posts are from the same language.
*
* @param bool $return_original_if_missing
*/
function filter_return_ori( $return_original_if_missing ) {
return true;
}
@ajaydsouza
ajaydsouza / bsearch-meta-field.php
Last active June 15, 2018 09:18
Better Search API Examples
<?php
// Fixes to disregard Hidden products and to add Author Billing field to Better Search plugin queries
function filter_bsearch_posts_join( $join ) {
global $wpdb, $author_search;
$join .= "
INNER JOIN $wpdb->postmeta AS pm ON ($wpdb->posts.ID = pm.post_id)
";
if ( $author_search ) {
$join .= "
INNER JOIN $wpdb->postmeta AS pma ON ($wpdb->posts.ID = pma.post_id)
@ajaydsouza
ajaydsouza / clean-files.sh
Created June 30, 2015 13:23
Delete DS_Store & Thumbs.db
sudo find . -name '*.DS_Store' -type f -delete
sudo find . -name 'Thumbs.db' -type f -delete
@ajaydsouza
ajaydsouza / rsync.sh
Last active March 29, 2016 09:34
rsync basic syntax
rsync -va --progress SourceFolder DestinationFolder
@ajaydsouza
ajaydsouza / tptn-api-examples.php
Last active July 25, 2023 19:18
Top 10 API examples
<?php
/*
* This example fetches the popular posts tracked by Top 10.
*
*/
if ( function_exists( 'get_tptn_posts' ) ) {
$settings = array(
'daily' => TRUE,
@ajaydsouza
ajaydsouza / crp-css-grid.css
Last active February 20, 2021 22:55
Contextual Related Posts Grid styles
.crp_related ul {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 10px;
margin: 0;
justify-items: center;
list-style: none;
}
.crp_related ul li {
text-align:center;
@ajaydsouza
ajaydsouza / NumberFormat.vba
Created May 9, 2015 16:50
Custom Number Format from Range
Sub NumberFormat()
' Range should be formatted as "TEXT";"TEXT"
Range("B2:B19").NumberFormat = Range("C2:C19").Value
End Sub
@ajaydsouza
ajaydsouza / crp-ajax-load-more.php
Last active April 27, 2019 16:18
Ajax Load More implementations
<?php
/*
* This example fetches the related posts and uses Ajax Load More to dynamically pull additional posts
*
*/
global $post;
$features = get_crp_posts_id( array(
'postid' => $post->ID,