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 | |
/* | |
* Requiere Advanced Custom Fields Plugin para WordPress | |
* http://www.advancedcustomfields.com/resources/relationship/ | |
* Query posts para el valor relación. | |
* Se usa meta_query LIKE para coincidir el ID como cadena "123" al valor de la base de datos array serializado como a:1:{i:0;s:3:"123";} | |
*/ | |
$productos = get_posts(array( | |
'post_type' => 'product', |
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 | |
/* | |
* Devuelve las entradas ordenadas de un objeto Post de WordPress | |
* Útil para ordenar Custom Post Types o Post Objects en Advanced Custom Fields | |
* Ejemplo objectRSort($post_objects, 'post_title'); */ | |
function objectRSort(&$object, $key) | |
{ | |
for ($i = count($object) - 1; $i >= 0; $i--) | |
{ |
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_filter( 'dashboard_glance_items', 'mostrar_cpt_escritorio', 10, 1 ); | |
function mostrar_cpt_escritorio( $items = array() ) { | |
//indicar el/los custom post types | |
$post_types = array('cursos','proyectos' ); | |
foreach( $post_types as $type ) { | |
if( ! post_type_exists( $type ) ) continue; | |
$num_posts = wp_count_posts( $type ); | |
if( $num_posts ) { | |
$published = intval( $num_posts->publish ); |
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_filter ('woocommerce_add_to_cart_redirect', 'woo_redirect_to_cart'); | |
function woo_redirect_to_cart() { | |
$cart_url = WC()->cart->get_cart_url(); | |
return $cart_url; | |
} |
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 $thumb_id = get_post_thumbnail_id(); | |
if ($thumb_id != 0) : // existe imagen destacada | |
$thumb_url = wp_get_attachment_image_src($thumb_id,'large', true); | |
$thumbnail_details = get_posts(array('p' => $thumb_id, 'post_type' => 'attachment')); | |
$titulo = $thumbnail_details[0]->post_title; | |
$leyenda = $thumbnail_details[0]->post_excerpt; | |
?> | |
<figure> | |
<img class="img-responsive" alt="<?= esc_attr($titulo); ?>" src="<?= esc_url($thumb_url[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
function add_responsive_class_content($content){ | |
$content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8"); | |
if (!empty($content)) { | |
$document = new DOMDocument(); | |
libxml_use_internal_errors(true); | |
$document->loadHTML(utf8_decode($content),LIBXML_HTML_NOIMPLIED); | |
$imgs = $document->getElementsByTagName('img'); | |
foreach ($imgs as $img) { |
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
add_action( 'init', 'define_series_taxonomy' ); | |
function define_series_taxonomy() { | |
$labels = array( | |
'name' => 'Serie', | |
'singular_name' => 'Serie', | |
'search_items' => 'Buscar Series', | |
'all_items' => 'Todos los Series', | |
'parent_item' => 'Serie Superior', |
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 | |
// extraemos valores de la taxonomía personalizada llamada series | |
$serie = get_the_terms( (int)$post->ID, 'series'); | |
if ( $serie && ! is_wp_error( $serie) ) : | |
// sólo un elemento de la categoria, primer elemento del array | |
// extraer id | |
$serie_id= $serie[0]->term_id; | |
// nombre | |
$serie_nombre = $serie[0]->name; | |
// vinculo a la página de archivo |
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 | |
// extraemos valores de la taxonomía personalizada llamada series via campo acf taxonomy | |
$serie = get_field('acf_post_taxserie'); | |
if ( $serie && ! is_wp_error( $serie) ) : | |
// sólo un elemento de la categoria, primer elemento del array | |
// extraer id | |
$serie_id= $serie[0]->term_id; | |
// nombre | |
$serie_nombre = $serie[0]->name; | |
// vinculo a la página de archivo |
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
// según solución propuesta en http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt | |
function wpse_allowedtags() { | |
// Add custom tags to this string | |
return '<br>,<p>'; | |
} | |
if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) : | |
function wpse_custom_wp_trim_excerpt($wpse_excerpt) { | |
$raw_excerpt = $wpse_excerpt; |
OlderNewer