Skip to content

Instantly share code, notes, and snippets.

View mafsdisseny's full-sized avatar

Miguel A. Fdez. mafsdisseny

View GitHub Profile
@mafsdisseny
mafsdisseny / functions.php
Last active October 15, 2015 08:14
This function returns a string without accents
<?php
//Function that returns a string without accents
//source: http://stackoverflow.com/a/11743977/2841746
function stripAccents($text_to_strip) {
return strtr(utf8_decode($text_to_strip), utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
}
?>
@mafsdisseny
mafsdisseny / update_taxonomy_count.sql
Created September 17, 2015 09:35
Wordpress, Update the count parameter for a taxonomy, after data migration. In this case, only specify the post type name, and the associated taxonomies will be updated.
UPDATE wp_term_taxonomy tt
SET count =
(SELECT count(p.ID) FROM wp_term_relationships tr
LEFT JOIN wp_posts p
ON (p.ID = tr.object_id AND p.post_type = 'post_type_name' AND p.post_status = 'publish')
WHERE tr.term_taxonomy_id = tt.term_taxonomy_id
)
<?php
//do not add in opening php tag
/**
* Custom Genesis Home Loop with Character Limitation on Excerpt
*
* @package Custom Genesis Home Loop with Character Limitation on Excerpt
* @author Neil Gee
* @link http://wpbeaches.com
* @copyright (c)2014, Neil Gee
@mafsdisseny
mafsdisseny / functions.php
Created May 24, 2015 09:47
Add genesis-structural-wrap and filter it through a template
<?php
// First we include it in the genesis-structural-wrap genesis declaration
add_theme_support( 'genesis-structural-wraps', array(
'header',
// 'nav',
// 'subnav',
'site-inner',
'footer-widgets',
'page-header-img', //here is it
'footer'
@mafsdisseny
mafsdisseny / functions.php
Last active October 15, 2018 16:33
Polylang language switcher with slugs, uses Genesis
//* Add language switcher polylang with slug inspite of names
//* Position header-right
add_action( 'genesis_header_right', 'custom_language_switcher');
function custom_language_switcher() {
echo '<ul class="custom-lang-switcher">';
pll_the_languages(array('show_names'=>1,'display_names_as'=>'slug'));
echo '</ul>';
}
<?php
/**
* Limit Search to Video
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-search-post-type/
*
* @param string search form
* @param string search text
* @param string button text
* @return string modified search form
@mafsdisseny
mafsdisseny / functions.php
Created April 22, 2015 13:18
Limit WordPress search to post titles, apply site-wide
<?php
// Buscar solo coincidencias en el titulo
// Source: http://www.paulund.co.uk/limit-wordpress-search-to-post-titles
function search_by_title_only( $search, &$wp_query )
{
global $wpdb;
if ( empty( $search ) )
return $search; // skip processing - no search term in query
$q = $wp_query->query_vars;
$n = ! empty( $q['exact'] ) ? '' : '%';
add_action( 'get_header', 'themeprefix_cpt_microdata' );
//Change microdata for events custom post type
function themeprefix_cpt_microdata() {
if ('event' == get_post_type()) {//change to your cpt
//add in the microdata changes
add_filter( 'genesis_attr_entry', 'themeprefix_genesis_attributes_entry', 20 );