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 | |
/** | |
* Get attachment image src for multiple posts at one time | |
* | |
* @param array $post_ids - The post IDs you want the featured image retrieved | |
* @param string $thumbnail_size - The thumbnail size name | |
* @return array - An array with the urls for the image srcs if they exist | |
*/ | |
function avenirer_get_attachment_image_src($post_ids = array(), $thumbnail_size = 'full') { | |
if(sizeof($post_ids) == 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
UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, ' ', ''); | |
UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, '\t', '' ); | |
UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, '\n', ''); | |
UPDATE wp_posts SET post_content = TRIM(Replace(Replace(post_content,'\t','')); |
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 | |
/** | |
* Retrieve an array of taxonomy terms that represent the parents of the given term | |
* | |
* @param $term_obj_or_id | |
* @param $taxonomy | |
* @param array $hierarchy | |
* | |
* @return array | |
*/ |
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 | |
// Solution started from: https://wordpress.stackexchange.com/questions/231448/how-to-add-dot-in-post-slug | |
// This will allow the "." character inside urls | |
function allow_htm_extensions( $title, $raw_title = '', $context = 'display' ) { | |
// IN HERE WE WRITE THE ACCEPTED EXTENSIONS | |
$allowed_extensions = array('.htm','.html'); | |
$title = strip_tags($title); | |
// Preserve escaped octets. | |
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); |
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 getMostUsedTaxonomies($taxonomy, $fields = 'all', $orderBy = 'count', $orderDirection = 'desc', $limit = '30') { | |
$transientName = 'mostUsedTaxonomies_'.$taxonomy.'_'.$fields.'_'.$orderBy.'_'.$orderDirection.'_'.$limit; | |
$mainTechnologies = get_transient( $transientName ); | |
if ( $mainTechnologies === false ) { | |
$params = array( | |
'taxonomy' => $taxonomy, | |
'hide_empty' => true, | |
'orderby' => $orderBy, | |
'order' => $orderDirection, |
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 debug_rewrite_rules() { | |
global $wp, $template, $wp_rewrite; | |
echo '<pre>'; | |
echo 'Request: '; | |
echo empty($wp->request) ? "None" : esc_html($wp->request) . PHP_EOL; | |
echo 'Matched Rewrite Rule: '; | |
echo empty($wp->matched_rule) ? None : esc_html($wp->matched_rule) . PHP_EOL; | |
echo 'Matched Rewrite Query: '; |
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 | |
// CUSTOMIZE EXCERPT LENGTH | |
function get_the_excerpt_limit($charlength = 200, $post = null, $readMoreStr = '[...]') | |
{ | |
$newExcerpt = ''; | |
if(isset($post)) { | |
$excerpt = strlen($post->post_excerpt) > 0 ? $post->post_excerpt : wp_strip_all_tags($post->post_content); | |
} | |
else { | |
$excerpt = get_the_excerpt(); |