Skip to content

Instantly share code, notes, and snippets.

View top-ten-query-standard-loop.php
<?php
// The Query.
$the_query = new Top_Ten_Query( $args );
// The Loop.
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
@ajaydsouza
ajaydsouza / standard-loop.php
Last active Jan 10, 2021
CRP_Query Examples
View standard-loop.php
<?php
// The Query.
$the_query = new CRP_Query( $args );
// The Loop.
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
View bsearch-html-markup.html
<!-- This is the sample markup generated by Better Search v2.3.0 for each article entry -->
<article id="post-1011" class="bsearch-post post-1011 post type-post status-publish format-standard has-post-thumbnail hentry category-codex category-corner-case category-featured-images category-images">
<header class="bsearch-entry-header">
<h2 class="bsearch-entry-title"><a href="https://wpnetwork.local/blog/featured-image-horizontal/" rel="bookmark">Featured Image (Horizontal)</a></h2>
<p><span class="bsearch_score">Relevance: 75%</span> &nbsp;&nbsp;&nbsp;&nbsp; <span class="bsearch_date">Posted on: March 15, 2013</span></p>
</header>
<div class="bsearch-entry-content">
@ajaydsouza
ajaydsouza / tptn-restyle-count.php
Last active Dec 21, 2018
Convert Top 10 count to use k, m and bn
View tptn-restyle-count.php
<?php
/**
* Modify the display the tptn counter to show k and m instead.
*
* Add this code to your theme's functions.php file or in a file in mu-plugins.
*
* @param $string $input Formatted list count
*/
function tptn_restyle_count( $input ) {
@ajaydsouza
ajaydsouza / crp_change_query_dates.php
Created Nov 18, 2018
Filter from and now date in Contextual Related Posts
View crp_change_query_dates.php
<?php
/**
* Filter crp_posts_from_date.
*
* @param string $where The Minimum date of the WHERE clause of the query.
* @param int $id Post ID
*/
function crp_same_date_from( $where, $id ) {
global $wpdb, $post;
@ajaydsouza
ajaydsouza / crp-vertical.css
Last active Nov 6, 2017
Contextual Related Posts styles
View crp-vertical.css
/* Vertical Related Posts */
/* The full list */
.crp_related ul li {
list-style-type:none;
/* float:left; */
margin:0 40px 0 0;
width: 230px;
}
@ajaydsouza
ajaydsouza / better-search-polylang.php
Last active Apr 25, 2020
Better Search and Polylang compatibility
View better-search-polylang.php
<?php
// Doesn't work.
/**
* Joins the taxonomy tables. Filters bsearch_posts_join.
*
* @param string $join
* @return string
*/
@ajaydsouza
ajaydsouza / Install automysqlbackup.md
Last active Dec 12, 2016 — forked from janikvonrotz/Install automysqlbackup.md
Ubuntu: Install automysqlbackup#MySQL#Markdown
View Install automysqlbackup.md

Introduction

AutoMySQLBackup with a basic configuration will create Daily, Weekly and Monthly backups of one or more of your MySQL databases from one or more of your MySQL servers.

Requirements

  • Ubuntu server
  • MySQL

Installation

@ajaydsouza
ajaydsouza / delete-old-post-meta.mysql
Last active Jun 14, 2017
Delete old wp post meta entries
View delete-old-post-meta.mysql
DELETE FROM `wp_postmeta`
where meta_key LIKE '_su_%'
OR meta_key LIKE '_aioseop_%'
OR meta_key LIKE '_sexybookmarks_%'
OR meta_key LIKE '%SexyBookmarks%'
OR meta_key LIKE '%OgTags%'
OR meta_key LIKE 'digg'
OR meta_key LIKE 'ratings_%'
OR meta_key LIKE '_utw_%'
OR meta_key LIKE 'dsq_%'
@ajaydsouza
ajaydsouza / crp-same-post-type.php
Created Mar 28, 2016
CRP - Limit to same post type
View crp-same-post-type.php
<?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;