This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'rest_endpoints', function( $endpoints ){ | |
if( isset( $endpoints[ '/wp/v2/posts' ] ) ){ | |
foreach( $endpoints[ '/wp/v2/posts' ] as &$post_endpoint ){ | |
if( ! empty( $post_endpoint[ 'methods' ] ) && 'GET' == $post_endpoint[ 'methods' ] ){ | |
$post_endpoint[ 'args' ][ 'type' ] = array( | |
'description' => 'Post types', | |
'type' => 'array', | |
'required' => false, | |
'default' => 'post' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dates = ['relation'=>'OR']; | |
$x = 1; | |
while( $x <= 5 ) : | |
$currentDate = new DateTime(); | |
$previous_date = $currentDate->sub( new DateInterval( "P{$x}Y" ) ); | |
$previous_year = $previous_date->format('Y'); | |
$currentDate = new DateTime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bootstrap_link_pages( $args = '' ) { | |
$defaults = array( | |
'before' => '<p>' . __( 'Pages:' ), | |
'after' => '</p>', | |
'link_before' => '', | |
'link_after' => '', | |
'next_or_number' => 'number', | |
'nextpagelink' => __( 'Next page' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Default Img for post thumbnails | |
* | |
* @param $file_name_new (string) Name of the newly-created file | |
* @param $file_name_orig (string) Filename of the original default image | |
* @param $post_id (int) ID of the associated Post | |
* @param $size (array) Width/height of cropped thumbnail | |
* @param $class (string) Optional class attribute for output image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add dynamic classes to the WP body_class() function | |
* | |
* updated: 01/06/16 | |
*/ | |
function _dbdb_body_classes( $classes ) { | |
global $wp_query, $post; | |
// if it's the front page of the site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create a dynamic id on body elements | |
* | |
*/ | |
function get_body_id( $id = '' ) { | |
global $wp_query; | |
// Fallbacks | |
if ( is_front_page() ) $id = 'front-page'; | |
if ( is_home() ) $id = 'blog'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Instagram scraper | |
* | |
* Quick and dirty Instragram scraper for displaying a Instagram feed. | |
* | |
* Based on : https://gist.github.com/cosmocatalano/4544576 | |
* | |
* @param string $username Instagram user account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'meta_key' => '_affiliatedCompany', | |
'meta_value' => $companyID, | |
'post_type' => 'article', | |
'posts_per_page' => 20, | |
); | |
$r = new WP_Query( $args ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dbdb_unset_rest_routes( $args, $post_type ) { | |
$allowed_post_types = array( 'page', 'post', 'company', 'job' ); | |
$allowed_post_types = apply_filters( 'dbdb_unset_rest_routes_types', $allowed_post_types ); | |
if( in_array( $post_type, $allowed_post_types ) ){ | |
return $args; | |
} else { | |
$args['show_in_rest'] = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function filter_tribe_bases( $bases = array() ){ | |
$rewriteSlug = sanitize_title( Tribe__Settings_Manager::get_option( ‘eventsSlug’, ‘events’ ) ); | |
$bases[‘archive’] = array( $rewriteSlug ); | |
return $bases; | |
} | |
add_filter( ‘tribe_events_rewrite_base_slugs’, ‘filter_tribe_bases’ ); |
NewerOlder