Skip to content

Instantly share code, notes, and snippets.

@ajaydsouza
ajaydsouza / filter_tptn_view_counter_script_url.php
Last active September 4, 2016 11:45
Alternate Tracking script - Filter script URL in Top 10 v2.x
<?php
/**
* Use external display of counter.
*
* @since 2.3.0
*
* @param string $home_url
* @return string
*/
@ajaydsouza
ajaydsouza / crp-plugin-api-examples.php
Last active December 1, 2022 20:16
Contextual Related Posts plugin API examples
<?php
/*
* This example fetches the related posts for the current post ID and displays the output in a custom format restricted by the 'news' category
*
*/
if ( function_exists( 'get_crp_posts_id' ) ) {
global $post;
$scores = get_crp_posts_id( array(
'postid' => $post->ID,
@ajaydsouza
ajaydsouza / timthumb-crp.php
Last active August 29, 2015 14:16
Timthumb in Contextual Related Posts & Top 10
<?php
/**
* Filter function to resize post thumbnail. Filters: crp_thumb_url.
*
* @since 1.8.4
*
* @param string $postimage
* @param string|int $thumb_width
* @param string|int $thumb_height
@ajaydsouza
ajaydsouza / tptn_display_formatted_count.php
Last active July 22, 2017 22:11
Top 10 - tptn_list_count filter examples
<?php
/**
* Display the formatted list count.
*
* Add this code to your theme's functions.php file.
*
* @param $string $tptn_list_count Formatted list count
*/
function tptn_display_formatted_count( $tptn_list_count, $sum_count, $result ) {
@ajaydsouza
ajaydsouza / top-10-grid.css
Last active August 29, 2015 14:18
Top 10: 2x Grid
.tptn_title {
float: left;
clear: left!important;
}
.tptn_thumb {
align: center!important;
}
.tptn_posts,
.tptn_posts_daily {
margin-bottom: 20px;
@ajaydsouza
ajaydsouza / tptn_viewed_count.php
Created April 18, 2015 17:55
Top 10 - Don't track nextpage
<?php
/**
* Filter_tptn_viewed_count function.
*
* @param string $output Top 10 tracker script
* @return string Filtered tracker script
*/
function filter_tptn_viewed_count( $output ) {
global $wp_query;
@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,
@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-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 / 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,