Custom admin menu for a selection of pages

Approach 1: You could assign the role of “editor” to the user, assign the user as author of the three pages and thereafter limit the user to editing only those three pages by following this outlined methodology: http://www.godaisies.com/2010/08/23/how-to-make-editors-only-able-to-edit-their-own-page-in-wordpress/ This however does not fulfill your requirement of a dedicated custom admin page. It simply limits what … Read more

how bbPress and buddypress add their own page templates to the page template drop down on the page editing screen

Sincerly I don’t know how Buddypress and bbPress add options to page templates dropdown, and I can be wrong, but I think the only way to do it (excluding adding files to theme folder or hacking core), is to use javascript. Create a file containing the following, save it somewhere, I will assume it is … Read more

Create a Page Template Which Displays All Posts by Current User

Working code: <?php if (is_user_logged_in() ) : ?> <?php //if a certain page, then display posts authored by the logged in user $page_title=”Support History”; if ( is_user_logged_in() && is_page($page_title) ) { global $current_user; get_currentuserinfo(); $args=array( ‘author’ => $current_user->ID, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish, private’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1 ); $my_query = null; $my_query … Read more

Time sort with meta_key using UNIX timestamp failing due to date differences

I will caveat this by saying that I am still not 100% sure I know what you are doing, but I believe the following will sort your results by time only assuming that your meta values are proper Unix timestamps. function orderby_time_only($orderby) { remove_action(‘posts_orderby’,’orderby_time_only’); return preg_replace(‘|(.*)\s(.*)|’,’DATE_FORMAT(FROM_UNIXTIME($1),”%k%i”) $2′,$orderby); } add_filter(‘posts_orderby’,’orderby_time_only’); $args = array( ‘post_type’ => ‘event’, … Read more

How to call uninstall.php?

Uninstall hook and uninstall.php file are two alternate ways to implement uninstall functionality, they are independent of each other. When uninstall_plugin() is called it checks for uninstall.php or hook (in this order). So if you are using file approach there is nothing special you need to do to call it. WordPress looks it’s up by … Read more

Add more levels to menu

Go to wp-content/themes/templatename/ and then in header.php go to his line ‘depth’ => apply_filters( ‘yiw_main_menu_depth’, 3), Just change the number and done!

WooCommerce product permalinks

Add a filter for post_type_link, and change its value in a callback function. Sample code, not tested: add_filter( ‘post_type_link’, ‘simple_woo_urls’, 10, 2 ); function simple_woo_urls( $url, $post ) { if ( ‘product’ === $post->post_type ) return home_url( $post->post_name ); return $url; }

Add internal page to admin menu

Yes, it’s possible. First of all you need a way to identify the page. there are different way to do it: by page slug, by page template… I suggest you to create a fucntion that retrieve that page. Let’s assume the contact page has a page template called ‘page-contacts.php’. function get_contact_page() { $args = array( … Read more