how to group custom post types

The filter Inside /wp-admin/menu.php, you’ll find this filter at the end of the “add css classes”-loop: apply_filters( ‘add_menu_classes’, $menu ) The function The following code attaches the right classes to the first and previous elements. It also adds the separator in between. If you need to add another separator to the end/after your group, you’ll … Read more

Using functions from a plugin in your theme

Yes, you can use functions from plugins in your theme. Please use the function_exists() function to make sure that the function does exit. I used the Breadcrumbs Plus in one of the themes like this: <?php if (function_exists(‘breadcrumbs_plus’)) { $breadcrumb_options = array( ‘prefix’ => ‘<div id=”breadcrumb”>’, ‘suffix’ => ‘</div>’, ‘title’ => ‘Du er her: ‘, … Read more

Declaring an instance of class included in parent theme from child theme functions.php

Handle all the class loading in your parent theme on a predictable action (point in time) and hook in later in your child theme. Example: add_action( ‘wp_loaded’, ‘parent_prefix_load_classes’, 10 ); function parent_prefix_load_classes() { $classes = [ ‘Extra_Comment_Walker’, ‘Extra_Nav_Menu_Walker’ ]; foreach ( $classes as $class ) { locate_template( “php/class.$class.php”, TRUE, TRUE ); } } Create instances … Read more

Set media upload attachment link to none and hide it in WP v3.5

Include this small plugin, activate and test. A tested version in 3.6-alpha, works only on click on a thumbnail. <?php /** * Plugin Name: Remove Attachment Link-To and set to value ‘none’ */ add_action( ‘admin_footer-post-new.php’, ‘wpse_76214_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_76214_script’ ); function wpse_76214_script() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $( ‘li.attachment’ ).live( ‘click’, function( … Read more

Can I turn off write-in tags/taxonomies?

Here is what I came up with, seems to work: add_filter( ‘pre_post_tags_input’, ‘no_tags_input_create’ ); add_filter( ‘pre_post_tax_input’, ‘no_tax_input_create’ ); function no_tags_input_create($tags_input) { $output = array(); foreach( $tags_input as $tag ) if( term_exists( $tag, ‘post_tag’) ) $output[] = $tag; return $output; } function no_tax_input_create($tax_input) { if( !isset($tax_input[‘post_tag’]) ) return $tax_input; $output = array(); $tags = explode(‘,’, $tax_input[‘post_tag’]); … Read more

add_action in a function, is it possible?

If you want to find out whether you’re on a specific page, post, in a category archive, etc., then core has to offer Conditional Tags for this. If you want to hook a js-script definition, then a better way to do this is the following: // Assuming that you drop your js code into a … Read more