Skip to content

Instantly share code, notes, and snippets.

Antonio Villegas avillegasn

Block or report user

Report or block avillegasn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@avillegasn
avillegasn / 01-loop-basico.php
Last active Aug 1, 2016
Entendiendo el Loop de WordPress
View 01-loop-basico.php
<?php
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
//contenido del loop (template tags, html, etc)
endwhile;
endif;
?>
View wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
View loop-avanzado.php
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// contenido de la entrada E (template tags, html, etc)
?><h2>
<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
</h2><?php
the_content();
// cogemos las etiquetas de la entrada E actual
@avillegasn
avillegasn / 00-Extender la WP REST API.md
Last active Feb 18, 2016
Código para extender la WP REST API
View 00-Extender la WP REST API.md
@avillegasn
avillegasn / estimar-tiempo-lectura-entrada-wordpress.php
Last active Feb 14, 2019
Código para calcular la estimación de tiempo necesario para leer una entrada en WordPress
View estimar-tiempo-lectura-entrada-wordpress.php
<?php
/**
* Estima el tiempo necesario para leer una entrada en WordPress
*
* @return string
*/
function wpr_estima_tiempo_lectura() {
$entrada = get_post();
View busqueda-shortcodes.php
<?php
function wprin_buscador_shortcode( $atts, $content=null ) {
ob_start();
extract( shortcode_atts( array( 'nombre' => '' ), $atts ) );
$string = $atts['nombre'];
$args = array( 's' => $string );
$the_query = new WP_Query( $args );
View parar-publicacion-wordpress.php
<?php // no copies esta línea
add_action( 'transition_post_status', 'comprueba_publicacion', 10, 3 );
function comprueba_publicacion( $new_status, $old_status, $post ) {
if ( 'publish' === $new_status ) {
// Comprueba que existe una imagen destacada
if ( !tiene_imagen_destacada( $post ) ) {
wp_die( 'Has olvidado incluir una imagen destacada.' );
View 00.Fragmentos-Codigo-WordPress.md
@avillegasn
avillegasn / wordpress-additional-files.php
Created Sep 29, 2016
How to allow uploading additional file extensions in WordPress
View wordpress-additional-files.php
<?php
add_filter( 'upload_mimes', 'my_myme_types', 1, 1 );
function my_myme_types( $mime_types ) {
$mime_types['svg'] = 'image/svg+xml'; // Adding .svg extension
$mime_types['json'] = 'application/json'; // Adding .json extension
unset( $mime_types['xls'] ); // Remove .xls extension
unset( $mime_types['xlsx'] ); // Remove .xlsx extension
return $mime_types;
You can’t perform that action at this time.