Fresh News - Blog Design, Wordpress, Blogger, and Web Development

Magznetwork Fresh News aggregate our favorite blogs to watch our favorite topics about blog design, wordpress themes, and blogger templates.

How to automatically create a custom field when a post is published

Paste the code below into your functions.php file. The only thing you have to do is to edit the cutsom field name on line 6. add_action(‘publish_page’, ‘add_custom_field_automatically’); add_action(‘publish_post’, ‘add_custom_field_automatically’); function add_custom_field_automatically($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, ‘field-name’, ‘custom value’, true); } } Thanks to wpCanyon for this cool tip! Looking for WordPress hosting?

Create custom “Read more” links on your WordPress blog

To achieve this recipe, the first step is to edit your posts and create custom fields. Give them custom_more as a key, and the text to display as a value.

WordPress: How to get custom fields outside the loop

To display a custom field value outside the loop, simply use the following code.

WordPress tip: Create invisible custom fields

This little trick is extremely simple: All you have to do is give a name starting with an underscore to your custom field when you create it, and it will not be displayed on WordPress dashboard when editing a post, as shown in the example below: add_post_meta($id, ‘_name’, ‘value’); Easy, isn’t it? And of course, very useful Thanks to my friend John Kolbert for the tip! Looking for WordPress hosting? Try WP Web Host

Custom Fields Hacks For WordPress

In our previous articles on WordPress hacks, we discussed the incredible flexibility of WordPress, which is one of the biggest reasons for its popularity among bloggers worldwide. Custom fields in particular, which let users create variables and add custom values to them, are one of the reasons for WordPress’ flexibility

Easily get posts with a specific custom field/value on your WordPress blog

To achieve this recipe, simply find the loop and add the query_posts() function just above, as in the example below: You’ll get the list of post having review_type as a custom field key and movie as a value . Just change theses values to fit your needs.

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]; Save the file. Now when you’ll write a new post, just create a custom field named mood and type your current mood as a value. Wanna make money blogging?

How to: Manually define to show full post or excerpt on your homepage

On your index.php file, replace your current loop by this one:

How to use a custom blurb when listing pages

The first thing to do is to paste the following code where you want your pages to be listed. It can be your sidebar, or a page template, for exemple. Once you saved your file, write some pages and add the custom_blurb custom field.