Conditionally include files in functions.php?

Use WordPress’ conditional tags, global variables, defines, class checks and the like. For instance like so: <?php // load helper functions – always require_once get_stylesheet_directory() . ‘/inc/helper-functions.php’; // load admin functions – for back-end only if ( is_admin() ) require_once get_stylesheet_directory() . ‘/inc/admin-functions.php’; // load WooCommerce functions – when WooCommerce is active if ( in_array( … Read more

wp_star_rating() – Adding a 5 star rating system to theme

Instead of redefining wp_star_rating() for the front end, you should be able to just use the built-in function. From the Codex page for wp_star_rating(): In order to use this function on the front end, your template must include the wp-admin/includes/template.php file and enqueue the appropriate dashicons CSS font information. (emphasis mine) A code sample is … Read more

Can not include file from plugin into theme

This is because you are trying to include a directory by URL, you need to call path, you can use the constant WP_PLUGIN_DIR. Modifying the variable acf_url to the following would work. $acf_url = WP_PLUGIN_DIR . ‘/advanced-custom-fields/acf.php’;