Articles of functions

Cleaner way to access custom fields in code?

I have 15 custom fields that I use to generate reviews for my site. Currently I access each field like this: //Buy or rent, type home, price if ( get_post_meta(get_the_ID(), ‘survey_home_type’, true) ) { echo get_post_meta(get_the_ID(), ‘survey_home_type’, true) . ” – “; } if ( get_post_meta(get_the_ID(), ‘survey_buy_or_rent’, true) ) { echo get_post_meta(get_the_ID(), ‘survey_buy_or_rent’, true) . […]

Theme options WP Editor

My text editor in Theme Options doesn’t have font color option. How can I add that? I’ve searched around the web, but no luck. On regular pages and posts I can see the font color option. I’m using Options framework. Here’s the code snippet: $options[] = array( ‘name’ => __(‘Main text block’, ‘options_check’), ‘id’ => […]

How do I know what variables are passed in a filter/action and what their meaning is?

Something I have seen several times now and I don’t understand is the following: In a theme’s functions.php a function is defined and then attached to a hook, like so (simplified example): function do_stuff($a, $b) { // Do stuff with $a and $b } add_filter( ‘bloginfo_url’, ‘do_stuff’, 10, 2 ); Basically I think I understand […]

Link Category Description

I’m pulling my hair out over this. In the Links manager, you can enter a description for the category (in addition to the link itself). However, in wp_list_bookmarks, there is no way to call this value anywhere. So how can I get it? I know it’s in the term_taxonomy table, under link_category. So is there […]

How to use wp_get_recent_posts with many post types?

I’ve tried displaying many post types (separated by comma) and it didn’t work. Is there a way to achieve this? $args = array( ‘numberposts’ => ‘5’, ‘post_type’ => ‘cpt1, cpt2, cptn’); $recent_posts = wp_get_recent_posts( $args ); Thanks for your input.

jQuery plugin function is not a function

I’m having a problem I’ve never seen before. In a very new WordPress install, I uploaded a theme I had been working on for a friend’s restaurant: The problem, as you can see, is that the jquery plugins for the homepage (.cycle) and the menu page (.easyAccordion) aren’t being recognized as functions in Firebug. […]

How to add .htaccess code through a function?

I need to add the following .htaccess code through a function <IfModule mod_deflate.c> # Insert filters AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp AddOutputFilterByType DEFLATE image/svg+xml # Drop problematic […]

Enqueue styles after a plugin

Is there a way to enqueue my style.css (and other stylesheets) AFTER a certain plugin enqueues its styles? Specifically, I want my style.css to overwrite cforms’s styles, but when I change the priority of the add_action, it doesn’t do anything. Here’s what I have: function rm_theme_styles() { wp_register_style( ‘rm_styles’, get_template_directory_uri() . ‘/style.css’, array(), null, ‘all’ […]

Change the footer text on the login page

I am customising the login page and would like to alter the footer text that takes the user back to the website. Ideally and as an example, changing it from the first image, to the second just below: I’ve searched around a bit but can’t seem to find the answer I’m looking for in modifying […]

Display height and width properties with the_post_thumbnail() or related function

Problem I want the height and width properties in the img element of the Featured Image for a post, page, or custom post type. Environment I have a custom theme based on the BlankSlate theme. The new twentyfifteen theme also does not display the properties. In Settings/Media, I have not changed the default image sizes. […]