Articles of functions

Word Count Function Preventing Permalink Editing

This code counts the number of words in an excerpt and adds it to the excerpt meta box in the post edit screen: http://snippi.com/s/sn3hk5p However, something about this code is preventing the editing of permalinks in the post edit screen and I am unable to identify the problem. Any ideas?

How to access function from outside of a class within this class in WP plugin?

I am developing a WP plugin called e.g. DD_Awesome_Plugin and this is my code so far (simplified version without additional code logic within class functions): class DD_Awesome_PLugin { public function __construct() { } public function add_menu_page() { add_options_page(‘DD Awesome PLugin’, ‘DD Awesome PLugin’, ‘administrator’, __FILE__, array(‘DD_Awesome_PLugin’, ‘display_options_page’)); } public function display_options_page() { $plugin_options = get_option(‘dd_my_awesome_plugin’); […]

Defining a global array in functions.php?

I try to create an array of years, which is avaible in my template-files and in at least one other function in the functions.php. function get_the_years() { global $year_arr = range(2001, date(‘Y’)); return $year_arr; } Then I want to use it in a function, which creates a term for every year in the custom taxonomy […]

How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page

This post shows how to remove unwanted fields from the media uploader. It works great, but I want to limit it to a custom-post-type and I can’t seem to figure out how to do it. I’ve tried the following code, but it doesn’t seem to work: add_filter(‘attachment_fields_to_edit’, ‘remove_media_upload_fields’, 10000, 2); function remove_media_upload_fields( $form_fields, $post ) […]

plugins_url() works everywhere but wp_reqister_script()

So I should probably mention up front that I’m developing a plugin so my url is ‘mysite.com/plugin’ (Just in case this is related to my issue. So, In my main plugin file (myplugin.php) I have added the following: $plugin_url = plugins_url(‘/my-plugin-directory/’); immediately followed by wp_enqueue_style(‘wp_enqueue_scripts’, $plugin_url . ‘css/boxes.css’); Great, so far so good. The plugin […]

Change ul class=“children” for wp_list_pages?

Hello I’m using this code to print a list of Pages and Subpages: <ul> <?php wp_list_pages(‘title_li=&depth=2&child_of=’); ?> </ul> It outputs: <ul> <li><a href=”#”>Page 1</a></li> <li><a href=”#”>Page 2</a> <ul class=”children”> <li><a href=”#”>Subpage 2a</a></li> <li><a href=”#”>Subpage 2b</a></li> </ul> </li> <li><a href=”#”>Page 3</a></li> <ul class=”children”> <li><a href=”#”>Subpage 3a</a></li> <li><a href=”#”>Subpage 3b</a></li> </ul> <li><a href=”#”>Page 4</a></li> </ul> Is there […]

Custom Post Types relationships

I have a custom post type for my videos. I need do related it with other post category. And i have 10 category Like this : Post Category – Video Category Tech Tech Marketing Marketing News News ………………… I want to do for this. I have a post Category Tech and I have custom post […]

How to speed up a wordpress function with multiple loops?

I am a PHP novice and wrote this function. It is an alphabetical navigation which shows only the letter that have posts in both that letter and the currently filtered “genero” taxonomy term. I use multiple taxonomy queries to find “artistas” posts that, for example, are tagged as both “rock” and “funk”. The function works […]

Can I remove the Rich Text box editor for a specific post?

A few months ago I asked a similar question: Is it possible to remove the main rich Text box editor? and got the following answer: function remove_pages_editor(){ remove_post_type_support( ‘page’, ‘editor’ ); } add_action( ‘init’, ‘remove_pages_editor’ ); This code removes the editor from all pages. Can I remove if from specific pages (by post-ID) somehow? Thanks!

Unhook jQuery from WooCommerce via `functions.php`?

So I am using the http://woothemes.com/woocommerce/ plugin for eCommerce and it’s registering jQuery local and conflicting with my default jQuery call from Google CDN. It took a long time but I isolated the issue to the following lines of code within woocommerce.php: $suffix = defined(‘SCRIPT_DEBUG’) && SCRIPT_DEBUG ? ” : ‘.min’; $lightbox_en = (get_option(‘woocommerce_enable_lightbox’)==’yes’) ? […]