Skip to content

Instantly share code, notes, and snippets.

View nathanp's full-sized avatar

Nathan Parikh nathanp

View GitHub Profile
@jo-snips
jo-snips / events-conditional-wrappers.php
Last active December 21, 2023 12:27
The Events Calendar: Basic Conditional Wrappers
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page
@retgef
retgef / pug-bomb.php
Created June 24, 2012 07:46
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
@BFTrick
BFTrick / functions.php
Created November 15, 2012 01:49
Rename Existing Section in WordPress Theme Customizer
// rename existing sections
$wp_customize->add_section( 'section_id' , array(
'title' => __('Section Title','mytheme'),
'priority' => 20,
));
@frankyonnetti
frankyonnetti / wordpress-post-type-name.php
Last active December 31, 2022 15:30
WordPress - get post type name #wordpress
<?php
$post_type = get_post_type_object( get_post_type($post) );
echo $post_type->labels->name;
?>
@chuckreynolds
chuckreynolds / wordpress-remove-seo-columns.php
Last active March 29, 2020 06:17 — forked from norcross/remove-seo-columns.php
remove WordPress SEO columns from admin post tables
<?php
function rkv_remove_columns( $columns ) {
// remove the Yoast SEO columns
unset( $columns['wpseo-score'] );
unset( $columns['wpseo-title'] );
unset( $columns['wpseo-metadesc'] );
unset( $columns['wpseo-focuskw'] );
<?php
// LOGOUT LINK IN MENU
function diww_menu_logout_link( $nav, $args ) {
$logoutlink = '<li><a href="'.wp_logout_url().'">Logout</a></li>';
if( $args->theme_location == 'primary' ) {
return $nav.$logoutlink ;
} else {
return $nav;
@alana-mullen
alana-mullen / Detect the last post in the WordPress loop
Last active May 29, 2023 16:50
Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@tjhole
tjhole / WORDPRESS: Get And Cache Vimeo Thumbnails
Created December 5, 2013 13:07
WORDPRESS: Get And Cache Vimeo Thumbnails
// Get And Cache Vimeo Thumbnails
function get_vimeo_thumb($id, $size = 'thumbnail_small')
{
if(get_transient('vimeo_' . $size . '_' . $id))
{
$thumb_image = get_transient('vimeo_' . $size . '_' . $id);
}
else
{
$json = json_decode( file_get_contents( "http://vimeo.com/api/v2/video/" . $id . ".json" ) );
@Strap1
Strap1 / Convert Custom Taxonomy to Custom Post Type
Last active September 8, 2022 23:37
A very hacky and quick way to transfer a Custom Taxonomy to Custom Post Type and transfer associated metadata to Custom Meta Fields. Note: You can use this if it fits your needs, but it is custom to my set up. Use in a testing environment. It's a plugin with no interface, runs on activation and depending on the amount of data, may hit PHP timeou…
<?php
/*
Plugin Name: Convert Custom Taxonomy to Custom Post Type
Plugin URI: N/A
Description: A plugin to convert a Custom Taxonomy to a Custom Post Type and transfer associated metadata.
Version: 0.1
Author: Strap1
Author URI: http:/www.hiphopinenglish.com
/** Convert Taxonomy '%name%' to CPT '%name%' **/
@pippinsplugins
pippinsplugins / gist:11402562
Last active December 15, 2021 17:07
Custom user fields for Restrict Content Pro
<?php
/*
Plugin Name: Restrict Content Pro - Custom User Fields
Description: Illustrates how to add custom user fields to the Restrict Content Pro registration form that can also be edited by the site admins
Version: 1.0
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Contributors: mordauk
*/