Articles of functions

Simple/basic use of get_current_screen

I would like to load a stylesheet on only 3 admin pages: post.php?post=7&action=edit post.php?post=10&action=edit post.php?post=18&action=edit I was trying with admin_enqueue_script but it doesn’t seem to be capable of such specificity (see my related wpse post), which led me to get_current_screen. But all the examples and articles I find about get_current_screen refer to using it with […]

Got white blank page after copying the functions.php to child theme

I got white blank page after copying the functions.php to my child theme. How can I change “like_escape”? What file can I find that? And I see this notice: Notice: like_escape is deprecated since version 4.0! Use wpdb::esc_like() instead. in /home7/homecre1/public_html/betasite/wp-includes/functions.php on line 3201 and that notice display here http://goo.gl/zgWVMQ I don’t use any plugin […]

Excerpt function for any content

Is there an excerpt output function in wordpress I can hook into regardless of the field used, rather than just the main content field? I have a CPT using custom fields, and rather than creating a function to output only X chars, appending an ellipse while taking into account trailing whitespace etc it would seem […]

How to get_template_directory() properly on local environment

I’m currently developing a site locally in MAMP PRO. When I use get_template_directory() inside of the standard functions.php file, the site path gets output correctly. However, I have a separate enqueue.php file that I use to enqueue my scripts. I’m using a require to include the enqueue.php file. require get_template_directory() . ‘/inc/enqueue.php’; My issue begins […]

WordPress function only executes once

I am trying to create a redirect for my authors so that when they login (and access the admin area) they are directed to the posts page instead of the WordPress dashboard. I found a function that works, but the function only works the first time the users access admin area. Each consecutive time they […]

Return child theme url

I’m trying to return the child theme url for a child theme favicon. The official code to use in this case is: //* Display a custom favicon add_filter( ‘genesis_pre_load_favicon’, ‘sp_favicon_filter’ ); function sp_favicon_filter( $favicon_url ) { return ‘http://www.mydomain.com/wp-content/images/favicon.ico’; } but adding absolute urls stresses me out 😉 I know that get_bloginfo(‘stylesheet_directory’) returns the correct url, […]

Plugin Development – Functions or Hooks?

I am brand new to WordPress plugin development and have a few questions, mostly about best practices but also some specifics. Essentially I just want to trigger an action (invoking a PHP class and calling a method) whenever the following happens: A post is published A page is published A comment is added This will […]

Format latest/newest post differently

I need to apply different formatting to only the latest/newest post. I need the first post to be full size image and full post, all subsequent posts must be excerpts with thumbnails. The code I am using only works on the first post per page so on the second page the first post is also […]

Every second post different class in blog view

To assign different classes to every 2nd post in blog view in WordPress adding this code into function.php was suggested as solution. Most people claim it is helpful, but to me it just adds odd at the end of the post class. There is no even class anywhere. function alternating_post_class($classes) { global $wp_query; $classes[] = […]

How to override woocommerce.css?

I would like to override woocommerce.css in my child theme. This is what I tried in my child theme’s functions.php but it does not seem to work: add_filter( ‘woocommerce_enqueue_styles’, ‘__return_false’ ); function wp_enqueue_woocommerce_style(){ wp_register_style( ‘woocommerce’, get_template_directory_uri() . ‘/css/woocommerce.css’ ); if ( class_exists( ‘woocommerce’ ) ) { wp_enqueue_style( ‘woocommerce’ ); } } add_action( ‘wp_enqueue_scripts’, ‘wp_enqueue_woocommerce_style’ );