5 Comments | Leave a Comment
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:
1029 | public function addEventBox( ) { |
1030 | add_meta_box( 'Event Details' , __( 'The Events Calendar' , 'Events_textdomain' ), |
1031 | array ( $this , 'EventsChooserBox' ), 'post' , 'normal' , 'high' ); |
With this:
1029 | public function addEventBox( ) { |
1031 | 'Event Details' , __( 'The Events Calendar' , 'Events_textdomain' ), |
1032 | array ( $this , 'EventsChooserBox' ), 'post' , 'normal' , 'high' ); |
1033 | add_meta_box( 'Event Details' , __( 'The Events Calendar' , 'Events_textdomain' ), |
1034 | 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:
01 | <?php query_posts( 'post_type=events&category_name=events&eventDisplay=upcoming' ); ?> |
Da Categorie(s): Code, Custom Post Types, Plugins, Wordpress
25 Comments | Leave a Comment
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:
89 | $html = '<input type="text" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . ' />' ; |
With this:
89 | $html = '<input type="text" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . ' onfocus="if(this.value==\'' ; |
90 | $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:
88 | $html = '<textarea name="' . $name . '"' . $atts . '>' . esc_html( $value ) . '</textarea>' ; |
With this:
88 | $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.
Da Categorie(s): Code, Plugins, Wordpress
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.
01 | register_post_type( 'products' , array ( |
02 | 'label' => __( 'Products' ), |
03 | 'singular_label' => __( 'Products' ), |
06 | 'capability_type' => 'post' , |
07 | 'hierarchical' => false, |
10 | '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
1 Comment | Leave a Comment
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
01 | http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=<? php the_permalink(); ?>&Title=<? php the_title(); ?> |
Delicious
01 | http://delicious.com/post?url=<? php the_permalink(); ?>&title=<? php the_title(); ?>&notes=<? php the_excerpt(); ?> |
Design Bump
01 | http://www.designbump.com/submit?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Design Float
01 | http://www.designfloat.com/submit.php?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Design Moo
01 | http://www.designmoo.com/submit?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Digg
01 | http://digg.com/submit?phase=2&url=<? php the_permalink(); ?>&title=<? php the_title(); ?>&bodytext=<? php the_excerpt(); ?> |
Diigo
01 | http://www.diigo.com/post?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Dzone
01 | http://www.dzone.com/links/add.html?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Facebook
01 | http://www.facebook.com/share.php?u=<? php the_permalink(); ?>&t=<? php the_title(); ?> |
Fark
01 | http://cgi.fark.com/cgi/fark/farkit.pl?h=<? php the_title(); ?>&u=<? php the_permalink(); ?> |
Friendfeed
01 | http://www.friendfeed.com/share?title=<? php the_title(); ?>&link=<? php the_permalink(); ?> |
Google Bookmarks
01 | http://www.google.com/bookmarks/mark?op=edit&bkmk=<? php the_permalink(); ?>&title=<? php the_title(); ?>&annotation=<? php the_excerpt(); ?> |
Hacker News
01 | http://news.ycombinator.com/submitlink?u=<? php the_permalink(); ?>&t=<? php the_title(); ?> |
Identi.ca
01 | http://identi.ca/notice/new?status_textarea=<? php the_permalink(); ?> |
Linked In
01 | http://www.linkedin.com/shareArticle?mini=true&url=<? php the_permalink(); ?>&title=<? php the_title(); ?>&summary=<? php the_excerpt(); ?> |
Live Favorites
01 | https://favorites.live.com/quickadd.aspx?marklet=1&url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Mister Wong
01 | http://www.mister-wong.com/addurl/?bm_url=<? php the_permalink(); ?>&bm_description=<? php the_title(); ?> |
Mixx
01 | http://www.mixx.com/submit?page_url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
MySpace
01 | http://www.myspace.com/Modules/PostTo/Pages/?u=<? php the_permalink(); ?>&t=<? php the_title(); ?> |
Netvibes
01 | http://www.netvibes.com/share?title=<? php the_title(); ?>&url=<? php the_permalink(); ?> |
Newsvine
01 | http://www.newsvine.com/_tools/seed&save?u=<? php the_permalink(); ?>&h=<? php the_title(); ?> |
Ping.fm
01 | http://ping.fm/ref/?link=<? php the_permalink(); ?>&title=<? php the_title(); ?>&body=<? php the_excerpt(); ?> |
Posterous
01 | http://posterous.com/share?linkto=<? php the_permalink(); ?>&title=<? php the_title(); ?>&selection=<? php the_excerpt(); ?> |
Propeller
01 | http://www.propeller.com/submit/?url=<? php the_permalink(); ?> |
Reddit
01 | http://reddit.com/submit?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Slashdot
01 | http://slashdot.org/bookmark.pl?title=<? php the_title(); ?>&url=<? php the_permalink(); ?> |
Sphere
01 | http://www.sphere.com/search?q=sphereit:<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Sphinn
01 | http://sphinn.com/index.php?c=post&m=submit&link=<? php the_permalink(); ?> |
StumbleUpon
01 | http://www.stumbleupon.com/submit?url=<? php the_permalink(); ?>&title=<? php the_title(); ?> |
Technorati
01 | http://technorati.com/faves?add=<? php the_permalink(); ?> |
Tipd
01 | http://tipd.com/submit.php?url=<? php the_permalink(); ?> |
Tumblr
01 | http://www.tumblr.com/share?v=3&u=<? php the_permalink(); ?>&t=<? php the_title(); ?>&s=<? php the_excerpt(); ?> |
Twitter
01 | http://twitter.com/home?status=<? php the_title(); ?> - <? php the_permalink(); ?> |
Yahoo Bookmarks
01 | http://bookmarks.yahoo.com/toolbar/savebm?u=<? php the_permalink(); ?>&t=<? php the_title(); ?> |
Yahoo Buzz
01 | 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
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:
01 | update wp_posts set post_status = replace (post_status, 'publish' , 'draft' ); |
02 | update wp_posts set post_status = replace (post_status, 'inherit' , 'draft' ); |
Da Tag(s): database, mySQL Da Categorie(s): Wordpress