Wordpress: Deshacerse de todos los shortcodes no utilizados

0 - , , - 03/01/2012 20:01:31

Los shortcodes de WordPress son muy útiles, pero hay un problema con ellos: una vez que se dejan de utilizar (por ejemplo, al cambiar a otro tema) te encontrará el texto de los shortcodes en los posts. La siguiente consulta te puede ser útil para eliminarlos. En este ejemplo se elimina el shortcode [tweet].

UPDATE wp_post SET post_content = replace(post_content, '[tweet]', '' ) ;

Visto en WP Recipes » »

WordPress: deshabilitar trackbacks hacia artículos del mismo blog

0 - , , - 08/09/2011 20:07:56

Los trackbacks son un sistema de aviso a otros bloggers de que un artículo de ellos ha sido enlazado desde nuestro blog. El problema con esto viene cuando enlazas un artículo de tu mismo blog, un trackback hacia ti mismo será mostrado en el artículo enlazado. Para evitar esto, podemos utilizar el siguiente código en el archivo functions.php:

function disable_self_ping( &$links ) {
    foreach ( $links as $l => $link ){
            if ( 0 === strpos( $link, get_option( 'home' ) ) ){
            		unset($links[$l]);
            }
	}
}
add_action( 'pre_ping', 'disable_self_ping' );

Deshabilitar los widgets por defecto de WordPress

0 - , , , - 21/07/2011 20:11:06

Si quieres eliminar los widgets por defecto de WordPress como Enlaces, Archivos, Posts recientes, etc, solo debes añadir el siguiente código al archivo functions.php:

function unregister_default_wp_widgets() {
        unregister_widget('WP_Widget_Pages');
        unregister_widget('WP_Widget_Calendar');
        unregister_widget('WP_Widget_Archives');
        unregister_widget('WP_Widget_Links');
        unregister_widget('WP_Widget_Meta');
        unregister_widget('WP_Widget_Search');
        unregister_widget('WP_Widget_Text');
        unregister_widget('WP_Widget_Categories');
        unregister_widget('WP_Widget_Recent_Posts');
        unregister_widget('WP_Widget_Recent_Comments');
        unregister_widget('WP_Widget_RSS');
        unregister_widget('WP_Widget_Tag_Cloud');
}
add_action('widgets_init', 'unregister_default_wp_widgets', 1);

WordPress: Añadir social media links a tus posts

0 - , , - 19/05/2011 18:29:00

El siguiente frágmento de código ha de insertarse en el bucle de posts y añade links para compartir tu contenido en Delicious, Digg, Twitter, Stumbleupon, Facebook, Blinklist, Furl y Reddit.

// bookmark on Delicious
<a rel="nofollow" href="http://delicious.com/post?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="Bookmark this post at Delicious">Bookmark at Delicious</a>

// submit to Digg
<a rel="nofollow" href="http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>" title="Submit this post to Digg">Digg this!</a>

// tweet on Twitter
<a rel="nofollow" href="http://twitter.com/home?status=<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Share this article with your Twitter followers">Tweet this!</a>

// submit to StumbleUpon
<a rel="nofollow" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post at StumbleUpon">Stumble this!</a>

// share on Facebook
<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Facebook">Share on Facebook</a>

// submit to Blinklist
<a rel="nofollow" href="http://blinklist.com/index.php?Action=Blink/addblink.php&url=<?php the_permalink(); ?>&Title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Blinklist" >Blink This!</a>

// store on Furl
<a rel="nofollow" href="http://furl.net/storeIt.jsp?t=<?php echo urlencode(get_the_title($id)); ?>&u=<?php the_permalink(); ?>" title="Share this post on Furl">Furl This!</a>

// submit to Reddit
<a rel="nofollow" href="http://reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Reddit">Share on Reddit</a>

Visto en css-tricks » »

Cómo mostrar los archivos adjuntos de un Post en WordPress

0 - , , - 13/05/2011 08:53:27

Desde WordPress 2.5, la gestión de archivos adjuntos en WordPress ha mejorado de un modo importante y ahora es muy potente. El siguiente fragmenteo de código puedes utilizarlo en tu tema de WordPress para mostrar los archivos adjuntos de un post.

Simplemente pega el siguiente código en cualquier lugar del archivo "post.php" y se mostrarán los archivos adjuntos.

$args = array(
  'post_type' => 'attachment',
  'numberposts' => null,
  'post_status' => null,
  'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
  foreach ($attachments as $attachment) {
    echo apply_filters('the_title', $attachment->post_title);
    the_attachment_link($attachment->ID, false);
  }
}

Visto en snipplr » »