Archive for: February, 2012

Create and verify a nonce

Feb 27 2012 Published by under Wordpress

All of this is created in a class

// place this in __construct of the class
$this->nonce_name = 'name_' . $my_post_type_slug;
$this->nonce_action = 'saving_posttype_' . $my_post_type_slug;
add_action('save_post', 'save_my_custom_posttype', 10);

// place this in a meta box
echo '
';

// your custom save w/ nonce
function save_my_custom_posttype($post_id) {

	if (isset($_POST[ $this->nonce_name ]) && wp_verify_nonce( $_POST[ $this->nonce_name ], $this->nonce_action ) !== false ) {
		// do something
	}
}

No responses yet

Redirect url to a page after importing posts

Feb 24 2012 Published by under How-to, Wordpress

After importing posts from one WordPress site to another, you need to set the htaccess file to direct the pages and images. Here’s what I used:

The old site where I exported posts is easterniowasportsandrec.com. I created a new page that will be a section page for these posts at http://thegazette.com/sports/more/. So I need to redirect the old homepage, the old stories and the images. I added these three rules to the htaccess file on easterniowasportsandrec.com.

# redirect old homepage to new page
RewriteCond %{HTTP_HOST} ^easterniowasportsandrec.com$ [NC]
RewriteCond %{REQUEST_URI} ^\/$
RewriteRule ^(.*)$ http://thegazette.com/sports/more/ [L,R=301]

# redirect files from old site /files/ to new site /wp-content/uploads/
RewriteCond %{HTTP_HOST} ^easterniowasportsandrec.com$ [NC]
RewriteRule ^(.*/)?files/(.*)$ http://thegazette.com/wp-content/uploads/$2 [R=301,L]

# redirect every other page to match the post’s permalink on new site
RewriteCond %{HTTP_HOST} ^easterniowasportsandrec.com$ [NC]
RewriteRule ^(.*)$ http://thegazette.com/$1 [L,R=301]

These are the example redirects:
redirect the homepage to a page
http://easterniowasportsandrec.com/

redirect an image
http://easterniowasportsandrec.com/files/2012/01/Iowa-vs.-Norhtwestern131-128×128.jpg

redirect a story
http://easterniowasportsandrec.com/2011/10/16/feels-like-spring-as-kernels-hold-pa-on-field-tryouts/

No responses yet

Upgrading WordPress 3.3.1 broke Postie plugin

Feb 17 2012 Published by under Wordpress

The get_user_by function breaks when calling _fill_user function. I commented out the get_user_by function and it worked fine.

http://wordpress.org/support/topic/postie-broken-in-33-_fill_user-problem

No responses yet