Tag Info

Hot answers tagged

7

At the risk of getting voted down by everybody else here who thinks this is OK. I say: No, you shouldn't define functions in template files. This should be considered bad practice. Let's have a look at the documentation: Functions File Explained. The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress ...


3

These queries are in the wp_enqueue_media() function: $has_audio = $wpdb->get_var( " SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'audio%' LIMIT 1 " ); $has_video = $wpdb->get_var( " SELECT ID FROM $wpdb->posts ...


2

customize should work. I was able to remove the Customize link with the following code: add_action( 'wp_before_admin_bar_render', 'wpse200296_before_admin_bar_render' ); function wpse200296_before_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu('customize'); }


2

Sure. If your function is really just doing some control switching, putting it into the template is fine. Anything more than that traditionally goes into functions.php or similar. Edit: +10 at Pieter Goosen's mention of trying to keep things DRY. It can actually be difficult to keep things DRY with WordPress theming. I'm a fan of the Sage starter theme. ...


1

There is no wrong or right way, neither is there any type of set rule or standard stating where custom code should go or not. This is all personal preference. There are few guidelines which you should use (if you want to) Templates (and all code for that matter) should be kept organised, maintainable, and easy to read and understand. Do not clot code ...


1

I wanted to achieve the same thing.. What I ended up doing was creating a function that collects the Kirki variables (see here about the use of variables in Kirki) and writes them to a scss.. $file = get_template_directory() . '/sass/custom/_custom_vars_mixins_options.scss'; if(file_exists($file)){ $output = ""; $variables = ...


1

Just small nuggets of information that may help in simple setups (most notably the ones with no use plugins using ob_start): 1) You don't need the to put dns-prefetch calls as the first elements. What you need is to put them as soon as possible before any other element calling external resources. 2) Is actually possible to use negative numbers as priority ...



Only top voted, non community-wiki answers of a minimum length are eligible