Skip to content

Instantly share code, notes, and snippets.

@DavidPeralvarez
DavidPeralvarez / index.php
Last active May 29, 2018 09:00
Mostrar una plantilla según Post Format
<?php
if ( have_posts() ):
while ( have_posts() ): the_post();
//Cargamos una plantilla u otra en función del formato de post
//El primer parámetro que recibe es el nombre del directorio que contiene las plantillas
get_template_part('template-parts', get_post_format());
endwhile;
endif;
?>
@DavidPeralvarez
DavidPeralvarez / index.php
Last active May 29, 2018 09:17
Mostrar Post Formats dentro del Loop de WordPress
<?php
if ( have_posts() ):
while ( have_posts() ): the_post();
//Mostramos el "slug" del formato de post
echo get_post_format();
endwhile;
endif;
?>
@DavidPeralvarez
DavidPeralvarez / functions.php
Last active May 29, 2018 08:40
Añadir soporte a Post Formats en WordPress
<?php
// Damos soporte a los Post Formats: Aside, Link, Image, Video y Quote
add_theme_support( 'post-formats', array( 'aside', 'link', 'image', 'video' , 'quote' ) );
@DavidPeralvarez
DavidPeralvarez / lesson-reply-notification.php
Created May 17, 2018 20:44
Aviso de respuesta a duda por correo
<?php
/*
Plugin Name: Lesson Reply Notification
Description: Send and email to the student, when he receives a response
Author: David Perálvarez
Version: 1.0
Author URI: https://silicodevalley.com
*/
add_action( 'wp_insert_comment', 'scv_comment_notification', 99, 2 );
@DavidPeralvarez
DavidPeralvarez / front-end-posting.php
Created May 17, 2018 15:48
WordPress Plugin Front End Posting
<?php
/*
Plugin Name: Front End Posting
Description: Create posts from the front end
Author: David Perálvarez
Version: 1.0
Author URI: https://silicodevalley.com
*/
// Front end submission form
@DavidPeralvarez
DavidPeralvarez / functions-fb.php
Created March 29, 2018 14:00
Imagen destacada de WordPress como Facebook Thumbnail
/**
* Facebook Thumb Fixer
*/
add_action('wp_head','fbfixthumbnail');
function fbfixthumbnail(){
global $post;
//If there is a post image
if (has_post_thumbnail()) {
<div id="main">
<header></header>
<ul>
<li class="item1"></li>
<li class="item2"></li>
<li class="item3"></li>
</ul>
<footer></footer>
</div>
@DavidPeralvarez
DavidPeralvarez / selectores-descendientes.css
Created March 29, 2018 13:38
(CSS) Selectores descendientes en CSS
body{
background-color: #f2f2f2;
width: 960px;
margin: 0 auto;
}
.post{
background-color: white;
padding: 20px;
}
@DavidPeralvarez
DavidPeralvarez / selectores-descendientes.html
Created March 29, 2018 13:37
(HTML) Selectores descendientes en CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="styles.css">
<title>Selectores descendientes en CSS</title>
</head>
<body>
<header id="main-header">
@DavidPeralvarez
DavidPeralvarez / selectores-id-clase.css
Created March 29, 2018 13:35
(CSS) Selectores de ID y de CLASE en CSS
header{
text-align: center;
}
#big-title{
font-size: 60px;
margin: 30px 0 0 0;
}
#subtitle{
font-style: italic;