For Multisite user website and for the customization for your client website, you have to make some modification in the WordPress core file, especiaaly modification and customization with Custom fields. Today we are comling a list of excellent resources for the utilization of custom field along with a list of tips and trick for its usages, so you can extend the features of WordPress powered websites for your clients and users.
Following are the list of useful resources that unveil the power of WordPress Custom Fields and you can find them very helpful to extend the Website features.
WordPress Custom Fields Tutorials, Tips and Tricks
There are limitless features which you can get from WordPress Custom fields by using WordPress Plugins or through customizing your themes file like WordPress frameworks: Theme frameworks extend the WordPress platform in a way that lets designers streamline additional features and functionality for their themes. Following are the best themes provider for Custom fields: Genesis Framework, Themify, upthemes, iThemeBuilder. There are lots of themes which can enhance the utilizing the custom fields for single post for customers and for multi-site users according to the requirements as follows:Adding Custom Fields for User Profiles
You can add this custom field by using user_contactmethods filter and change it as you need it, add following piece of code in your theme's function.php file as I have tried it in U-Design WordPress Theme: // adding custom fields to WP user profile function wparena_profiles( $contactmethods ) { // Add Twitter $contactmethods['blog_title'] = 'Blog Title'; // Add Google profile $contactmethods['google'] = 'Google+ URL'; // Add Twitter $contactmethods['twitter'] = 'Twitter ID'; //add Facebook $contactmethods['facebook'] = 'Facebook Profile URL'; return $contactmethods; } add_filter('user_contactmethods','wparena_profiles',10,1); // end of adding custom fields to WP user profile
Source: Adding Custom Fields in WordPress User Profiles – Tip for Multi-Authors Blogs
How to: Set post expiration date/time on your WordPress blog
Do you regret that WordPress haven’t a feature to publish a post during only 2 days, or one week? Here is a very nice code that you can use in your WordPress theme, to enable the possibility of creating post expiration based on date and time.<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
$expirationtime = get_post_custom_values('expiration');
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}
$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween > 0 ) {
// For exemple...
the_title();
the_excerpt();
}
endwhile;
endif;
?>
Source: How to: Set a post’s expiration date and time on your WordPress blog
How to: Manually define to show full post or excerpt on your homepage
Do you use excerpts or full posts on your blog excerpts? Personnally, I think they’re both good. The only problem is that you can’t, by default, use both excerpts and full posts on your blog homepage. Here’s a code to do it. On your index.php file, replace your current loop by this one:<?php if (have_posts()) :
while (have_posts()) : the_post();
$customField = get_post_custom_values("full");
if (isset($customField[0])) {
//Custom field is set, display a full post
the_title();
the_content();
} else {
// No custom field set, let's display an excerpt
the_title();
the_excerpt();
endwhile;
endif;
?>
Source: How to: Manually define whether to show full posts or excerpts on your home page
Display the Digg Button only when the custom field is present
<?php
// check for digg button for single page
$digg = get_post_meta($post->ID, 'Digg', $single = true);
// if there's a single page digg button
if($digg !== '') { ?>
<script type="text/javascript">
(function() {
var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://widgets.digg.com/buttons.js';
s1.parentNode.insertBefore(s, s1);
})();
</script>
<a></a>
<?php } // end if statement
// if there's not a digg button
else { echo ''; } ?>
Source: How to Add a Digg Button Using Custom Fields
How to: Display your current mood on your posts
Open your single.php file (You can also modify your index.php file) and paste the following code anywhere within the loop:$customField = get_post_custom_values("mood");
if (isset($customField[0])) {
echo "Mood: ".$customField[0];
Source: How to: Display your current mood on your posts
Add Meta Descriptions To Your Posts
Open your header.php file. Paste the following code anywhere within the <head> and </head> tags:<meta name="description" content="
<?php if ( (is_home()) || (is_front_page()) ) {
echo ('Your main description goes here');
} elseif(is_category()) {
echo category_description();
} elseif(is_tag()) {
echo '-tag archive page for this blog' . single_tag_title();
} elseif(is_month()) {
echo 'archive page for this blog' . the_time('F, Y');
} else {
echo get_post_meta($post->ID, "Metadescription", true);
}?>">
Sources: Unique meta description and meta keyword tags in your WordPress themes
How to: Link to some external ressource in post title
The first thing to do is to open your functions.php file and paste the following code:function print_post_title() {
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$post_keys = array(); $post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='url1' || $pkey=='title_url' || $pkey=='url_title') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
}
} else {
$link = $perm;
}
echo '<h2><a href="'.$link.'" rel="bookmark" title="'.$title.'">'.$title.'</a></h2>';
}
Once done, open your index.php file and replace the standard code for printing titles:
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>by a call to our newly created print_post_title() function:
<?php print_post_title() ?>Now, whenever you feel like let your post title leave your blog and point someplace else, just scroll down in your post writing screen, create or select a custom key named url1 or title_url or url_titleand put that external URL in value box. Sources: Hacking WordPress theme: external URL for post title How to: Link to an external resource in the post’s title
How to: Embed CSS in your posts with a custom field
open your header.php file and insert the following code between the <head> and </head> html tags:<?php if (is_single()) {
$css = get_post_meta($post->ID, 'css', true);
if (!empty($css)) { ?>
<style type="text/css">
<?php echo $css; ?>
</style>
<?php }
} ?>
Source: How to: Embed CSS in your posts with a custom field
How to: Redifine title tag with a custom field
Open your header.php file for edition. find the <title> tag, and replace it by the following code:<title>
<?php if (is_home () ) {
bloginfo('name');
} elseif ( is_category() ) {
single_cat_title(); echo ' - ' ; bloginfo('name');
} elseif (is_single() ) {
$customField = get_post_custom_values("title");
if (isset($customField[0])) {
echo $customField[0];
} else {
single_post_title();
}
} elseif (is_page() ) {
bloginfo('name'); echo ': '; single_post_title();
} else {
wp_title('',true);
} ?>
</title>
Source: How to: Redefine the title tag with a custom field
Disable Search Engine Indexing For Individual Posts
To achieve, first get the ID of the post you'd like to be not indexed by search engines. In this exemple, I assume your post id is 17. Open your header.php file and paste the following code between the <head> and </head> tags: <?php if ($post->ID == 17) {
echo '<meta name="robots" content="noindex">';
}
Source: How to: disable search engine indexing of a single post
How to: Easily get the value of a custom field
You have to paste it on your theme functions.php file. If your theme doesn't have a file named functions.php, create one.function get_custom_field_value($szKey, $bPrint = false) {
global $post;
$szValue = get_post_meta($post->ID, $szKey, true);
if ( $bPrint == false ) return $szValue; else echo $szValue;
}
Now, to call the function and get your custom field value, use the following code:
<?php if ( function_exists('get_custom_field_value') ){
get_custom_field_value('featured_image', true);
} ?>
First, we use the php function_exists() function to make sure the get_custom_field_value function is defined on our theme. If it is, we use it. The first argument is the custom field name (here,featured_image) and the second let you echo the value (true) or get it for further use in php (false).
Sources: Useful custom functions for WordPress
How to: Easily get the value of a custom field
Rewrite Guest Author’s name with Custom Fields
Open your functions.php file and paste the codes belowadd_filter( 'the_author', 'guest_author_name' );
add_filter( 'get_the_author_display_name', 'guest_author_name' );
function guest_author_name( $name ) {
global $post;
$author = get_post_meta( $post->ID, 'guest-author', true );
if ( $author )
$name = $author;
return $name;
}
Source: How to rewrite Guest Author Name with Custom Fields in WordPress
Display Custom Fields Outside the Loop in WordPress
All you have to do is display the custom fields like this:<?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'Your-Custom-Field', true); wp_reset_query(); ?>Source: How to Display Custom Fields outside the loop in WordPress You will need to open your single.php or page.php file and find the following code:
<?php get_sidebar(); ?>Replace it with the following:
<?php global $wp_query; $postid = $wp_query->post->ID; $sidebar = get_post_meta($postid, "sidebar", true); get_sidebar($sidebar); wp_reset_query(); ?>Source: Display Different Sidebar for Each WordPress Post
Manipulating the RSS feed content with Custom Fields
Did you ever want to add a specific content just for your RSS readers in a specific post? Well this can also be done with custom fields. In this first example, we will show you how you can use custom field to display specific text/object in your WordPress RSS Feed. This trick will allow you to show different text, advertisement, image, or anything else for each post. Source: Completely Manipulate Your WordPress RSS Feeds WordPress, add content to its RSS feed!More Custom Field Tutorials and Hacks
Following are the list of useful resources that unveil the power of WordPress Custom Fields and you can find them very helpful to extend the Website features.
How to use WordPress Custom Fields
WordPress gives an author the ability to add extra data to each written post and page. This data is called meta-dataand is stored in custom fields.Using WordPress Custom Fields: Introduction
This tutorial series will cover more advanced uses later in the series. Mostly, he covered what he thought practical uses of custom fields.Add Thumbnails to WordPress with Custom Fields
You can find detailed article about how to add Thumbnails with custom fields to your WordPress post. Gave you detail about what is Custom field and how to use it to display Custom Thumbnails to particular post.Using WordPress Custom Fields
WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can include bits of information such as:- Mood: Happy
- Currently Reading: Cinderella
- Listening To: Rock Around the Clock
- Weather: Hot and humid













Responses (0 )