
Mais uma vez um post sobre wordpress, mas desta vez não vos trago só uma coisa, mas sim 10! Dez dicas e hacks que podes utilizar para melhorar o teu blog em wordpress.
Algumas já podem ser conhecidas vossas outras não. Brevemente irei fazer mais posts destes. Espero que vos seja útil.

Botão grande:
<script type="text/javascript"> tweetmeme_source = 'tweetmeme'; </script> <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"> </script> |
Botão pequeno:
<script type="text/javascript"> tweetmeme_source = 'tweetmeme'; tweetmeme_style = "compact"; </script> <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"> </script> |

<?php $my_query = new WP_Query('post_status=future&order=DESC&showposts=5'); if ($my_query->have_posts()) { while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <li><?php the_title(); ?></li> <?php endwhile; } else { echo "Sem posts agendados"; } ?> |
Fonte: http://www.wprecipes.com/how-to-list-scheduled-posts

Adicionar ao ficheiro functions.php do theme.
function my_custom_login_logo() { echo '<style type="text/css"> h1 a { background-image:url('.get_bloginfo('template_directory').'/images/custom-login-logo.gif) !important; } </style>'; } add_action('login_head', 'my_custom_login_logo'); |
Fonte: http://www.wprecipes.com/customize-wordpress-login-logo-without-a-plugin

1- Adiciona ao ficheiro functions.php do theme:
function scratch99_fromasearchengine(){ $ref = $_SERVER['HTTP_REFERER']; $SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.'); foreach ($SE as $source) { if (strpos($ref,$source)!==false) return true; } return false; } |
2- Adiciona este código onde queres que apareça o ad.
<?php if (function_exists('scratch99_fromasearchengine')) { if (scratch99_fromasearchengine()) { TEU CÓDIGO ADSENSE AQUI. } } ?> |
Fonte: http://www.scratch99.com/2008/09/avoid-smart-pricing-show-adsense-only-to-search-engine-visitors/

1- Adiciona ao ficheiro functions.php do theme:
function edit_comment_link($id) { if (current_user_can('edit_post')) { echo ' - <a href="'.admin_url("comment.php?action=editcomment&c=$id").'">Editar</a>'; } } |
2- Adicionar onde quiseres que apareça no ficheiro comments.php do teu theme.
<?php edit_comment_link(get_comment_ID()); ?> |
Fonte: http://www.wprecipes.com/how-to-add-del-and-spam-buttons-to-your-comments

Adiciona este código ao teu theme(na sidebar.php por exemplo):
<h2>Posts Populares</h2> <ul> <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5"); foreach ($result as $post) { setup_postdata($post); $postid = $post->ID; $title = $post->post_title; $commentcount = $post->comment_count; if ($commentcount != 0) { ?> <li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"> <?php echo $title ?></a> {<?php echo $commentcount ?>}</li> <?php } } ?> </ul> |
Fonte: http://www.problogdesign.com/wordpress/create-your-own-popular-posts-page/

1- Adiciona ao ficheiro functions.php do theme:
function is_old_post($post_id=null){ $days = 15; global $wp_query; if(is_single() || is_page()) { if(!$post_id) { $post_id = $wp_query->post->ID; } $current_date = time(); $offset = $days *60*60*24; $post_id = get_post($post_id); $post_date = mysql2date('U',$post_id->post_date); $cunning_math = $post_date + $offset; $test = $current_date - $cunning_math; if($test > 0){ $return = true; }else{ $return = false; } }else{ $return = false; } return $return; } |
2- Adiciona este código no ficheiro single.php onde quiseres que a pub apareça.
<?php if(is_old_post()){ ?> O TEU AD AQUI. <?php } ?> |

<?php $tags = wp_get_post_tags($post->ID); if ($tags) { echo '<h3>Posts Relacionados</h3>'; $first_tag = $tags[0]->term_id; $args = array( 'tag__in' => array($first_tag), 'post__not_in' => array($post->ID), 'showposts' => 7, //numero de posts 'caller_get_posts' => 1 ); $my_query = new WP_Query($args); if ($my_query->have_posts()) { ?> <ul> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> <?php } ?> <?php } ?> |

Este código irá mostrar todos os ficheiros que enviaste a partir de um post. Tens de o colocar no loop do post.
<?php $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); } } ?> |
Fonte: http://snipplr.com/view.php?codeview&id=5375
As vezes pode ser util, porque vai haver sempre aquele espertinho que vai meter textos em negrito e italico só para dizer que sabe html. lol
Para desactivares só precisas de adicionar este código ao ficheiro functions.php.
// This will occur when the comment is posted function plc_comment_post( $incoming_comment ) { // convert everything in a comment to display literally $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']); // the one exception is single quotes, which cannot be #039; because WordPress marks it as spam $incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] ); return( $incoming_comment ); } // This will occur before a comment is displayed function plc_comment_display( $comment_to_display ) { // Put the single quotes back in $comment_to_display = str_replace( ''', "'", $comment_to_display ); return $comment_to_display; |
Tem ai alguns que me vão fazer jeito.
Normalmente uso plugins para fazer o que ai tens mas assim sem plugins torna-se melhor.
Responder@Nelson Paiva: Ainda bem que te é útil!
ResponderBoas dicas, continua
ResponderMuito bom mesmo.
bgd
ResponderVoltast com as dicas, feedbacks positivos..
ResponderSocial comments and analytics for this post…
This post was mentioned on Twitter by LibertyTuga: [LibertyTuga]: 10 Hacks e Dicas Para o Wordpress http://libertytuga.com/2010/01/26/10-hacks-e-dicas-para-o-wordpress/...
Algumas são muito boas!
Não conhecia nenhuma, mas vou começar a usar isso, sem dúvida..
ResponderE para mostrar o código assim como tens, é algum plugin ?
Responder@ORiOn:
Vou ter que martelar mais um bocado… Já estive a testar mais nunca funciona.
Obrigado
Responder@Celso Azevedo: Esse plugin? Se esse não funciona tenta outros
Existe mais.
http://wordpress.org/extend/plugins/search.php?q=Code+Highlighter&sort=
Responder@Celso Azevedo: LOL Força
Responder[...] ver mais 10 hacks e dicas no LibertyTuga. Tags: 5, dicas, hacks, lista, [...]
Não tens Gravatar? Clica aqui para saberes como ter o teu avatar pessoal(gravatar)!
26 de Janeiro de 2010 ás 20:00