Skip to content

Instantly share code, notes, and snippets.

View jpcontrerasv's full-sized avatar
🏠
Working from home

Juan Pablo Contreras Valdés jpcontrerasv

🏠
Working from home
View GitHub Profile
<?php echo get_post_meta($post->ID, 'user_submit_name', true); ?>
@jpcontrerasv
jpcontrerasv / Siteurl + Template URL.php
Last active August 29, 2015 14:04
Siteurl + Template URL
<?php echo get_option('siteurl'); ?>
<?php bloginfo('template_url'); ?>
<?php bloginfo('stylesheet_url'); ?>
<?php wp_head(); ?>
<?php wp_footer(); ?>
<?php the_post_thumbnail( $size, $attr ); ?>
@jpcontrerasv
jpcontrerasv / Paginar Post Type.php
Last active October 21, 2015 15:43
Paginar Post Type
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=5&post_type=blog'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php endwhile; ?>
@jpcontrerasv
jpcontrerasv / WP > Print a Sidebar.php
Created July 30, 2014 14:53
WP > Print a Sidebar
<?php dynamic_sidebar( 'Single Sidebar' ); ?>
@jpcontrerasv
jpcontrerasv / WP > ACF For each post.php
Created July 30, 2014 14:53
WP > ACF For each post
<?php $post_relacionados = get_field('artículos_relacionados');
if( $post_relacionados ): ?>
<?php foreach( $post_relacionados as $post): ?>
<?php setup_postdata($post); ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
@jpcontrerasv
jpcontrerasv / WP > Term name & Count.php
Created July 30, 2014 14:53
WP > Term name & Count
<?php
global $wpdb;
$terms = get_terms("categorias-y-tipos");
$count = count($terms);
$n = 0;
if ( $count > 0 ){
foreach ( $terms as $term ) {
$n++;
$querystr = "
@jpcontrerasv
jpcontrerasv / WP > Register Nav Menu.php
Created July 30, 2014 14:53
WP > Register Nav Menu
register_nav_menus( array(
'primary' => 'Magazine',
'secondary' => 'En Bici',
'tertiary' => 'La Bici',
'fortiary' => 'Baik Bici'
) );
@jpcontrerasv
jpcontrerasv / WP > Term Name.php
Last active September 25, 2015 15:23
WP > Term Name
$terms = get_the_terms( $post->ID , 'categorias' );
if($terms) {
foreach( $terms as $term ) {
echo $terminowp = $term->name;
}
}
@jpcontrerasv
jpcontrerasv / WP > Add image size.php
Created July 30, 2014 14:53
WP > Add image size
add_image_size('thumb-banner-mini', 376, 88, true);
@jpcontrerasv
jpcontrerasv / WP > Register post type.php
Created July 30, 2014 14:53
WP > Register post type
register_post_type('banner_mini', array(
'labels' => array(
'name' => __('Banners') ,
'singular_name' => __('Banner') ,
'add_new' => _x('Agregar nuevo', 'banner_mini') ,
'add_new_item' => __('Agregar nuevo banner') ,
) ,
'public' => true,
'has_archive' => false,
'show_ui' => true,