How to add Shortcode (font awesome) in widget title?

I checked your code in my install. It works, except that you made a typo (missing backslash): [icon]cog[/icon] Few notes: You must make sure to enqueue the Font Awsesome stylesheet. You must close the shortcode, like: [icon]cog[/icon] Remember to escape the class name with esc_attr(). Another shortcode idea: [fa icon=”cog”]

Append taxonomy terms as class names in markup?

Differ the output until you have a collection ready. $terms = get_the_terms( $post->ID, ‘teams’ ); // create a collection with your default item $classes = array(‘person’); foreach ($terms as $term) { // add items $classes[] = $term->slug; } // output all the classes together with a space to separate them. echo ‘<div class=”‘ . implode(‘ … Read more

Create an array from an array

You can split your array using the following $array = array(1,2,3,4,5,6); $number_of_elements = 3; $count = count( $array ); $split = array(); for ( $i = 0; $i <= $count – 1; $i++ ) { $slices = array_slice( $array, $i , $number_of_elements); if ( count( $slices ) != $number_of_elements ) break; $split[] = $slices; } … Read more

How to get custom image size for image uploaded in Customizer

Apparently, your mod is storing the complete path to the image as a string. That leaves you little alternative but to do a search and replace on the string: $img = get_theme_mod(‘image-1’); if (!empty ($img)) { $img = preg_replace (‘.(jpg|jpeg|png|gif)$’,’-525×350$0′); if (!file_exists($img)) $img = get_template_directory_uri().’/images/default.jpg’; } else if (!file_exists($img)) $img = get_template_directory_uri().’/images/default.jpg’; In words. Get … Read more

Using a javascript file to access a get posts array

Yep, you’re looking for wp_localize_script(). Do away with the global. add_action( ‘wp_enqueue_scripts’, ‘wpse_enqueue_scripts’ ); function wpse_enqueue_scripts() { wp_enqueue_script( ‘wpse-main’, get_template_directory_uri() . ‘/path/to/script.js’, array(), false, true ); wp_localize_script( ‘wpse-main’, ‘wpseVars’, array( ‘postsLoop1’ => json_encode( /* first post array */ ), ‘postsLoop2’ => json_encode( /* second post array */ ), ‘postsLoop3’ => json_encode( /* third post array … Read more

WordPress doesn’t include css

You’ve placed the relevant code inside function.php, but WordPress loads functions.php You’re also missing some indenting which makes syntax errors much more likely to occur, and you can save some typing by using get_stylesheet_uri() instead of get_template_directory_uri().’/style.css’

Get value of contact form 7 radio button [closed]

Depending when you’d like to take the action you should change the hook – I’ve chosen wpcf7_before_send_mail – your function function wpcf7_cstm_function($contact_form) { $title = $contact_form->title; $submission = WPCF7_Submission::get_instance(); if ($submission) { $posted_data = $submission->get_posted_data(); $txt = isset($posted_data[‘txt’])?$posted_data[‘txt’]:”; $text2 = isset($posted_data[‘txt2’])?$posted_data[‘txt2’]:”; $radio = isset($posted_data[‘radio’][0])?$posted_data[‘radio’][0]:”; // do something with your data } } add_action(“wpcf7_before_send_mail”, “wpcf7_cstm_function”); Explanation: … Read more