Articles of functions

Include Jquery libraries in wordpress theme?

I have a file in my theme’s JS folder named cycle2.js. How do I include the Jquery from ‘wordpress→includes’ into my theme? How do I load this custom JavaScript file ‘cycle2.js’ into my theme? I have: function watercolor_js_scripts(){ if (!is_admin()) { wp_register_script(‘cycle2’, get_template_directory_uri() . ‘/js/cycle2.js’, ‘jquery’, TRUE); wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘cycle2’ ); } add_action(‘init’, […]

Function to replace comment's accented characters before posting

I have some weird problems with encoding my WordPress website and I can’t add comments with accent words. when i try to do it, i received error by WP. What i need is just a function that read the comment before it has inserted and transforms all the accented characters with normal characters with no […]

Change Slug of a Custom Post Type

I use a plugin that creates a custom post type with a slug that I am wanting to change. I don’t want to overwrite the plugin files, so I’m wondering how I can change the slug using a separate function? Thanks. // Register post type add_action( ‘init’, ‘ctc_register_post_type_item’ ); function ctc_register_post_type_item() { // Arguments $args […]

Showing user profile data on front-end

I’m making a profile-page so my members can update they’re details trough the front-end. The problem is that the select-box named “Province” won’t show the correct data when the page loads. How can i make the select-box load the correct data when the user enters the page? Here is the code i have in functions.php […]

How to register a menu based on a ACF condition

I am trying to register a WordPress menu, depending on a ACF field condition. $logo = get_field(‘logo’,’options’); if ($logo) { register_nav_menus(array( ‘brand_centered_left’ => __(‘Brand Centered Navigation (Left)’, ‘roots’) )); } However, if I test this code, the navigation does not show. It seems like ACF and functions.php does not work well together, but im not […]

How to add the post ID (or any other post data) to a Contact Form 7 mail?

I’ve downloaded Contact Form 7 to add contact forms adding a simple snippet after every post, and I’ve added it in functions.php like this : //if post type I add a form function is_post_type($type) { global $wp_query; if($type == get_post_type($wp_query->post->ID)) return true; return false; } function add_post_content($content){ if(!is_feed() && !is_home()&& is_single() && is_post_type(‘post’)) { $content […]

Visual Composer creating own shortcodes with vc_map() to return simple Image

I am using the Plugin Visual Composer with in a new Theme I develop. My question is about mapping shortcodes to Visual Composer arrays. The problem I get, when I try to make a custom element for an image. So here is what I did: I created an php file vc_shortcodes.php for my arrays of […]

Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS

I’ve been having trouble Automatically Compiling my .scss files into my main WordPress style.css file. I’m using Leafo’s SCSSPHP script and trying to achieve a few things. i’m using Kirki ( to override the WordPress Theme Customizer and this is what i’m trying to do. Create my Panels/ Sections/ Settings in the theme customizer like […]

Send post changes to set email addresses (not users or subscribers)

What I have I am using the “The Events Calendar” plugin on my site to coordinate a team of employees. I want to be able to send an automated email containing the body of an event post (post-type is not $post, but $tribe_events instead) each time it’s updated, but only to the employees concerned by […]

If user is logged-in display/hide something

I want to check at page load if the user is logged in or not and hide the login mask I programmed accordingly. There is a reason I’m using said login mask instead of redirecting to the WordPress standard login. The idea was to use functions.php: if ( is_user_logged_in() ) { echo ‘<li id=”text-2″ style=”display:none;”>’; […]