The Events Calendar and Custom Post Types
The Events Calendar plugin is outstanding for tracking events within WordPress sites and blogs. The integration of templates into your own theme means you don’t risk overwriting updates each time you upgrade the plugin. This is probably the strongest event calendar plugin we’ve used, but that doesn’t mean there aren’t some tweaks that could be made. Unfortunately, all events are listed as regular posts in WordPress; this works fine, but if you’re a neat-freak like we are, you like to have everything in its own place using custom post types. Because The Events Calendar doesn’t support custom post types (yet), we have to force it a little. It’s actually pretty easy and only take a little bit of code to complete, check it out below.
On line 1029 of this file:
/wp-content/plugins/the-events-calendar/the-events-calendar.class.php
Replace this:
public function addEventBox( ) { add_meta_box( 'Event Details', __( 'The Events Calendar', 'Events_textdomain' ), array( $this, 'EventsChooserBox' ), 'post', 'normal', 'high' ); }
With this:
public function addEventBox( ) { add_meta_box( 'Event Details', __( 'The Events Calendar', 'Events_textdomain' ), array( $this, 'EventsChooserBox' ), 'post', 'normal', 'high' ); add_meta_box( 'Event Details', __( 'The Events Calendar', 'Events_textdomain' ), array( $this, 'EventsChooserBox' ), 'events', 'normal', 'high' ); }
The word “events” on line 6 is the name of your custom post type. We use “events” because, well, they are events.
Now that the events are showing in your custom post types, you’ll need to edit the events templates, these are kept in the “events” directory within your theme. All you need to do is tweak the query to pull the custom post type, so add the following line of code right before the loop starts:
<?php query_posts('post_type=events&category_name=events&eventDisplay=upcoming'); ?>
Da Categorie(s): Code, Custom Post Types, Plugins, Wordpress
Contact Form 7 Clear Default Value
Contact Form 7 is one of our favorite form plugins because its updated regularly and there are a ton of extensions you can install that make the user-experience that much more rewarding; our favorite is the Database Extension. One feature that people have been asking about for quite some time is the ability to clear the default value of a field onClick or onFocus. This can be done easily by changing a couple lnes of code in the plugin, but remember, when you upgrade Contact Form 7, you’ll need to reapply this change.
On line 89 in this file:
/wp-content/plugins/contact-form-7/modules/text.php
Replace this:
$html = '<input type="text" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . ' />';
With this:
$html = '<input type="text" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . ' onfocus="if(this.value==\''; $html = $html . esc_attr( $value ) . '\') this.value=\'\';" onblur="if(this.value==\'\') this.value=\'' . esc_attr( $value ) . '\';" />';
And on line 88 in this file:
/wp-content/plugins/contact-form-7/modules/textarea.php
Replace this:
$html = '<textarea name="' . $name . '"' . $atts . '>' . esc_html( $value ) . '</textarea>';
With this:
$html = '<textarea name="' . $name . '"' . $atts . ' onblur="if (this.value == \'\') {this.value = \'' . esc_html( $value ) . '\';}" onfocus="if (this.value == \'' . esc_html( $value ) . '\') {this.value = \'\';}">' . esc_html( $value ) . '</textarea>';
With those 2 tweaks you should be able to clear the default value each time the user clicks the text field or text area.
Custom Post Types
Comments Off on Custom Post Types
Okay, if you’re not impressed with WordPress yet, you’ve got to take alook at 3.0. The development team has really made some significant updates for power users. Those who love to develop wordpress sites, like we do, you’re gonna love having the ability to create your won custom post types.
To implement this most excellent feature, just paste the following into your themes functions.php file and tweak to your delight.
register_post_type('products', array( 'label' => __('Products'), 'singular_label' => __('Products'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title', 'editor', 'author') ));
Can’t get much easier than that. Having this ability will allow us, as Wrodpress developers, to create more custom user interfaces for the content management systems we produce. Have fun with it!
Da Tag(s): cms, content management system, functions, php, techniques Da Categorie(s): Wordpress
Social Bookmarking Link Codes
How many times have you been building a custom WordPress theme and had to search for the appropriate social bookmarking link needed for your design? Well, search no more, you’ll find all the major players below:
Blinklist
http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=<?php the_permalink(); ?>&Title=<?php the_title(); ?>
Delicious
http://delicious.com/post?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>&notes=<?php the_excerpt(); ?>
Design Bump
http://www.designbump.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Design Float
http://www.designfloat.com/submit.php?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Design Moo
http://www.designmoo.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Digg
http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>&bodytext=<?php the_excerpt(); ?>
Diigo
http://www.diigo.com/post?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Dzone
http://www.dzone.com/links/add.html?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
http://www.facebook.com/share.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>
Fark
http://cgi.fark.com/cgi/fark/farkit.pl?h=<?php the_title(); ?>&u=<?php the_permalink(); ?>
Friendfeed
http://www.friendfeed.com/share?title=<?php the_title(); ?>&link=<?php the_permalink(); ?>
Google Bookmarks
http://www.google.com/bookmarks/mark?op=edit&bkmk=<?php the_permalink(); ?>&title=<?php the_title(); ?>&annotation=<?php the_excerpt(); ?>
Hacker News
http://news.ycombinator.com/submitlink?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>
Identi.ca
http://identi.ca/notice/new?status_textarea=<?php the_permalink(); ?>
Linked In
http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>&summary=<?php the_excerpt(); ?>
Live Favorites
https://favorites.live.com/quickadd.aspx?marklet=1&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Mister Wong
http://www.mister-wong.com/addurl/?bm_url=<?php the_permalink(); ?>&bm_description=<?php the_title(); ?>
Mixx
http://www.mixx.com/submit?page_url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
MySpace
http://www.myspace.com/Modules/PostTo/Pages/?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>
Netvibes
http://www.netvibes.com/share?title=<?php the_title(); ?>&url=<?php the_permalink(); ?>
Newsvine
http://www.newsvine.com/_tools/seed&save?u=<?php the_permalink(); ?>&h=<?php the_title(); ?>
Ping.fm
http://ping.fm/ref/?link=<?php the_permalink(); ?>&title=<?php the_title(); ?>&body=<?php the_excerpt(); ?>
Posterous
http://posterous.com/share?linkto=<?php the_permalink(); ?>&title=<?php the_title(); ?>&selection=<?php the_excerpt(); ?>
Propeller
http://www.propeller.com/submit/?url=<?php the_permalink(); ?>
http://reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Slashdot
http://slashdot.org/bookmark.pl?title=<?php the_title(); ?>&url=<?php the_permalink(); ?>
Sphere
http://www.sphere.com/search?q=sphereit:<?php the_permalink(); ?>&title=<?php the_title(); ?>
Sphinn
http://sphinn.com/index.php?c=post&m=submit&link=<?php the_permalink(); ?>
StumbleUpon
http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
Technorati
http://technorati.com/faves?add=<?php the_permalink(); ?>
Tipd
http://tipd.com/submit.php?url=<?php the_permalink(); ?>
Tumblr
http://www.tumblr.com/share?v=3&u=<?php the_permalink(); ?>&t=<?php the_title(); ?>&s=<?php the_excerpt(); ?>
http://twitter.com/home?status=<?php the_title(); ?> - <?php the_permalink(); ?>
Yahoo Bookmarks
http://bookmarks.yahoo.com/toolbar/savebm?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>
Yahoo Buzz
http://buzz.yahoo.com/submit/?submitUrl=<?php the_permalink(); ?>&submitHeadline=<?php the_title(); ?>&submitSummary=<?php the_excerpt(); ?>&submitCategory=science&submitAssetType=text
Da Categorie(s): Uncategorized
Change the Status of all WordPress Posts
Comments Off on Change the Status of all WordPress Posts
We recently worked on a project where the client had a blog they wanted reskinned to match a new site design. During development, they decided to start this blog from scratch with all new posts, but they still wanted to keep the older posts just in case they needed to reference them at some point. This can be done fairly easily via the database, and here it the SQL to do it:
update wp_posts set post_status = replace(post_status, 'publish', 'draft'); update wp_posts set post_status = replace(post_status, 'inherit', 'draft');