Check If Post In Custom Taxonomy

Filed Under (Light Reading, Wordpress Tips) by Wpfeed on 29-12-2011

Custom taxonomies is a great tool, you can create by yourself more ways to categorized posts or custom posts and in that way use wordpress as much better and advanced CMS.

suprisingley there isn’t yet a function to use if you want to check if a post is attached to a custom taxonomy (unless you check it with a single term of that given taxonomy – like in this example – http://wordpress.org/support/topic/custom-taxonomies-conditional-tags?replies=13#post-1110167)

let’s say you created a custom taxonomy called “video”, and you want to display different border to the featured image in the LOOP or any other icon near this post to show that it is a video.

you can use this function which returns the list of objects of a given taxonomy:

$video_terms = wp_get_object_terms($post->ID, ‘video’);
if(!empty($video_terms)){
if(!is_wp_error( $video_terms )){
//show your icon or any other sign of this taxonomy
}
}

Popularity: 1% [?]

Exclude Specific Author From RSS

Filed Under (How To, Wordpress Tips) by Wpfeed on 15-09-2011

sometimes you wish not to display one or more of your authors in RSS feed of your blog, it can be a test user or any other reason.

here is the code to paste in your functions.php

function wp_exclude_author($query) {
 if ($query->is_feed) {
 $query->set('author','-1'); //Author ID
 }
return $query;
}
add_filter('pre_get_posts','wp_exclude_author');

if you wish to exclude more authors just use space and another user ID with minus, like that:

$query->set('author','-1 -5'); //Author ID



Popularity: 3% [?]

Display Random Posts In WordPress

Filed Under (How To, Wordpress Tips) by Wpfeed on 13-09-2011

Sometimes in your theme you want to display random posts or maybe random related posts in your sidebar,

here’s an easy way to do it.

in your single.php or index.php, change the main loop to:

<?php

query_posts(array('orderby' => 'rand', 'showposts' => 1)); 
if (have_posts()) : while (have_posts()) : the_post(); ?> 
<h1><a href="<?php the_permalink() ?>">
<?php the_title(); ?></a></h1> <?php the_content(); ?> 
<?php endwhile; endif; ?>

Popularity: 3% [?]

Display Facebook Comments Count Anywhere In Your Blog

Filed Under (How To, Wordpress Tips) by Wpfeed on 12-09-2011

if you are using facebook comments social plugin for your blog comments, you can use this code snippet to display comments counter.

paste it where you want to display the counter. if you’re outside of the wordpress Loop use - get_permalink( $id ); instead of the_permalink();.

<fb:comments-count href=”<?php the_permalink();?>”></fb:comments-count> Comments

Popularity: 2% [?]

Remove WordPress Admin Bar

Filed Under (How To, Wordpress Tips) by Wpfeed on 11-09-2011

From version 3.1 wordpress has an admin bar at the top of the blog displayed all the time if you are logged in. if you with to remove it from the theme and not by css tricks, paste this code into your functions.php:

 

remove_action('init', 'wp_admin_bar_init');

Popularity: 2% [?]

Change Author Name Or Style Automatically

Filed Under (How To, Wordpress Tips) by Wpfeed on 10-09-2011

let's say you have a sponsored author you want to display in bold or
maybe change the font size or color. you can do it automatically with WordPress.
inside the function.php paste this function, just don't forget to change
the NAME_OF_AUTHOR to the name of the author you wish to take care of.
function custom_author_name( $name ) { global $post; if ($name == 'NAME_OF_AUTHOR'){
 $name = '<font color=#761B4A><b>' . $name . '</b></font>'; } return $name; } 
add_filter( 'the_author', 'custom_author_name' );

Popularity: 2% [?]

Use Your Post Featured Image In Facebook Share Automatically

Filed Under (How To, Wordpress Tips) by Wpfeed on 09-09-2011

when sharing on facebook or even pressing the "like" button,
your featured image of the post will show as the default image.
if no featured image you can tell the function to use your LOGO.
just paste this code in functions.php, don't forget to tell
the function where your logo is (SOURCE_TO_YOUR_LOGO).
function insert_image_src_rel_in_head() {
 global $post;

 if ( !is_singular()) //if it is not a post or a page do nothing
 return;

 if(!has_post_thumbnail( $post->ID )) {
 $default_image="SOURCE_TO_YOUR_LOGO"; 
 echo '<meta property="og:image" content="' . $default_image . '"/>';
 }
 else{
 $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
 echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
 }
 echo "\n";
}
add_action( 'wp_head', 'insert_image_src_rel_in_head', 5 );

Popularity: 2% [?]

How To Disable Upgrade WordPress Notification

Filed Under (How To, Installation, Wordpress Tips) by Wpfeed on 08-09-2011

very easily you can disable the sometimes annoying  message from wordpress reminding you to upgrade your wordpress. it is recommended to turn it off especially in multi author websites.

in your function.php, paste this code:

add_filter( ‘pre_site_transient_update_core’, create_function( ‘$a’, “return null;” ) );

Blog Widget by LinkWithin

Popularity: 2% [?]


Theme Forest
mojo themes
elegant themes
press75.com
wopshow

free wordpress 3.0 theme - wp3theme Theme