This is what I came up with to display the category, or rather a custom taxonomy, of a single posttype page of use in a breadcrumb. The taxonomy I used is ‘smg-logo-brand’ and the terms slug where ‘kcrg’, ‘the-gazette’ and ‘sourcemedia.’ I compared the terms associated with the post to that in the URL to [...]
Custom post type capabilities
$custom_posts_caps = array('edit_custom_post', 'read_custom_post', 'delete_custom_post', 'edit_custom_posts', 'edit_others_custom_posts', 'publish_custom_posts', 'read_private_custom_posts'); _smg_add_cap('administrator', $custom_posts_caps); _smg_add_cap('editor', $custom_posts_caps); 'capabilities' => array( 'edit_post' => 'edit_custom_post', 'read_post' => 'read_custom_post', 'delete_post' => 'delete_custom_post', 'edit_posts' => 'edit_custom_posts', 'edit_others_posts' => 'edit_others_custom_posts', 'publish_posts' => 'publish_custom_posts', 'read_private_posts' => 'read_private_custom_posts' ),
Create and verify a nonce
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[ [...]
Redirect url to a page after importing posts
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 [...]
Upgrading WordPress 3.3.1 broke Postie plugin
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
Adding or Removing Profile Fields
function my_contactmethods( $contactmethods ) { // add $contactmethods['twitter'] = ‘Twitter’; $contactmethods['facebook'] = ‘Facebook’; $contactmethods['blog'] = ‘Blog’; // remove unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); return $contactmethods; } add_filter(‘user_contactmethods’,'my_contactmethods’,10,1);
Adding a meta_box to all Post Types
$post_types = get_post_types( array( ‘_builtin’ => false ), ‘objects’ ); // Gets all custom types array_push( $post_types, get_post_type_object( ‘post’ ), get_post_type_object( ‘page’) ); // Adds back the ‘post’ and ‘page’ types while ommitting attachments, revisions, menus, etc. foreach ( $post_types as $type ) { add_meta_box( . . . ); }
WP-o-Matic breaks WordPress Related Links
function adminInit() { auth_redirect(); // force display of a certain section $this->section = ($this->setup) ? ((isset($_REQUEST['s']) && $_REQUEST['s']) ? $_REQUEST['s'] : $this->sections[0]) : ‘setup’; // if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], ‘MSIE’) !== false)) // die(‘Please switch to Firefox / Safari’); wp_enqueue_script(‘prototype’); wp_enqueue_script(‘wpoadmin’, $this->tplpath . ‘/admin.js’, array(‘prototype’), $this->version); if ($this->section == ‘list’) wp_enqueue_script(‘listman’); //if ( WPOTools::isAjax() ) [...]
NextGen Gallery fails to create new gallery
For some reason the slug field was missing in the wp_6_ngg_gallery on one of my WordPress multisite blogs. The fix . . . ALTER TABLE `wp_6_ngg_gallery` ADD `slug` VARCHAR( 255 ) NULL AFTER `name`; ALTER TABLE `wp_6_ngg_pictures` ADD `image_slug` VARCHAR NOT NULL AFTER `pid`