Skip to content

Instantly share code, notes, and snippets.

@antorome
Last active January 4, 2016 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antorome/b76cbdae202a4d22efe3 to your computer and use it in GitHub Desktop.
Save antorome/b76cbdae202a4d22efe3 to your computer and use it in GitHub Desktop.
<?php
function cdb_producto_afiliacion( $producto = "" ){
if ( empty( $producto ) ){
global $post;
$producto = $post->post_type ;
}
if ( false === ( $producto_afiliacion = get_transient( $producto . "_afiliacion" ) ) ) {
$producto_afiliacion = false;
if ( cdb_is_post_type( $producto ) ){
$args = array(
"post_type" => $producto,
"seccion" => "mejores-ofertas"
);
$query = new WP_Query ( $args );
if ( $query->have_posts() )
$producto_afiliacion = true;
wp_reset_post_data();
}
set_transient( $producto . "_afiliacion", $producto_afiliacion, 60*60*24 );
}
return $producto_afiliacion;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment