martes, 23 de abril de 2013

plugins pa que no se me olviden

Advanced Custom Field - para poner campos personalizados bonitos en páginas y posts

Viper's Video Quicktags - para saubir videos en posts y páginas
Simple Image Widget  - Crea un widget para subir ina imagen sola.
Video Sidebar Widgets - Para poner videos en el sidebar, tiene varios opciones, como videos random.
Fancybox - Es el que uso para las galerías de imágenes
Formulario de Contacto 7 - El plugín que uso para los formularios de contacto, manda mails.
wp-PageNavi - Para paginar los archivos de posts.

miércoles, 27 de febrero de 2013

Añadir breadcrumbs (menú de navegación) en páginas y entradas de wordpress

En el functions:


// Insertar Breadcrumb  
function the_breadcrumb() {
if (!is_home()) {
echo '<a href="';
echo get_option('home');
       echo '">';
echo 'Inicio';
echo "</a> » ";
if (is_category() || is_single()) {
the_category('title_li=');
if (is_single()) {
echo " » ";
the_title();
}
} elseif (is_page()) {
echo the_title();
}
}
}  
// fin breadcrumb

y se agregan así:

<?php the_breadcrumb(); ?>

lunes, 7 de enero de 2013

esto es para poder corregir errores en las tres versiones de internet explorer


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if IE 9]>    <html class="no-js ie9 oldie" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/estilos.css" type="text/css" rel="stylesheet"/>

<!-- Google webfont: Archivo Narrow-->
<link href='http://fonts.googleapis.com/css?family=Archivo+Narrow:400,700,400italic,700italic' rel='stylesheet' type='text/css' />


</head>

jueves, 11 de octubre de 2012

añadir un campo en el editor de posts de wordpress

Por ejemplo, si se quiere agregar un "subtítulo", se mete lo siguiente en el functions.php (también se puede meter en un archivo y subirlo a la carpeta plugins):



add_action('admin_menu', 'agregar_campos');
function agregar_campos() {
        add_meta_box('subtitulo','Subtítulo','fn_subtitulo','post','normal','high');
}

function fn_subtitulo() {
        global $wpdb, $post;
        $value  = (get_post_meta($post->ID, subtitulo, true));
        echo '<label class="hidden" for="subtitulo">Subtítulo</label>
        <input type="text" name="subtitulo" id="subtitulo" value="'.htmlspecialchars($value).'" style="width: 600px;" />';
}

add_action('save_post', 'guardar_campos');
add_action('publish_post', 'guardar_campos');
function guardar_campos() {
   global $wpdb, $post;
        if (!$post_id) $post_id = $_POST['post_ID'];
        if (!$post_id) return $post;
        $subtitulo= $_POST['subtitulo'];
        update_post_meta($post_id, 'subtitulo', $subtitulo);
}

add_action('delete_post', 'borrar_campos');
function borrar_campos() {
   global $wpdb, $post;
        if (!$post_id) $post_id = $_POST['post_ID'];
        if (!$post_id) return $post;
        delete_post_meta($post_id, 'subtitulo');
}


y después se llama al campo dentro del loop:

<?php echo get_post_meta($post->ID, subtitulo, true); ?>

lunes, 8 de octubre de 2012

twitter button en el loop de wordpress

el siguiente es el código:


<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
   <a href="http://twitter.com/share" class="twitter-share-button"
      data-url="<?php the_permalink(); ?>"
      data-via="USUARIO DE TWITTER SIN @"
      data-text="<?php the_title(); ?>"
      data-related="brp"
      data-count="vertical">Tweet</a>



donde:
data-url – This fetches the URL that you want to share (You do not need to change this).
data-via – This tells twitter who was the original tweeter by adding via @wpbeginner (Make sure you change it to your twitter account).
data-text – This fetches the title of your post (You do not need to change this).
data-related – This adds recommended users to follow. You are allowed up to two Twitter accounts for users to follow after they share content from your website. These accounts could include your own, or that of a contributor or a partner. The first account is the one that is shared in data-via property. (Make sure you change it to one of your other twitter accounts, or remove it). If you don’t, then you will be recommending @syedbalkhi (Founder of WPBeginner). The correct format to enter data in this variable is twitterusername:Description of the User
data-count – This tells twitter’s script which style of button you want to show. You have three option (vertical, horizontal, none). data-lang – This variable tells twitter which language it should be in. Default value is ‘en’ for English, and we have left it at that.

jueves, 27 de septiembre de 2012

Sumar valor a variable con jQuery

Para que no se me olvide la sintaxis:


        <script type="text/javascript">
$(document).ready(function(){
var $alturaSidebar = $("#sidebar").height()-20;
$("#content").css("min-height", $alturaSidebar );
});
</script>

lunes, 24 de septiembre de 2012

Borrar valor por defecto de un input con jquery


<script type="text/javascript">
  $(document).ready(function(){
   $('input').each(function(){
     // tomamos el valor actual del input
     var currentValue = $(this).val();
     // en el focus() comparamos si es el mismo por defecto, y si es asi lo vaciamos
     $(this).focus(function(){
     if( $(this).val() == currentValue ) {
     $(this).val('');
     };
     });
     // en el blur, si el usuario dejo el value vacio, lo volvemos a restablecer
     $(this).blur(function(){
     if( $(this).val() == '' ) {
     $(this).val(currentValue);
     };
     });
  });
 });
 </script>