Understanding child theme functions.php

What I read is that the parent css was loaded after the child, so the last one wins It depends on the order in which theme developer is loading stylesheets. Normally WordPress loads child theme’s functions.php first and then parent theme’s functions.php. the parent Emmet theme uses CSS files called differently than Style.css Yes it … Read more

Block PHP Files Nginx

Ok found the answer. You need to put this directive above the location: location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } The order apparently matters inside the nging conf file.

Database “Migration” for Plugins?

Surprisingly not. Instead, you need to use the following function which is run whenever the plugin is activated. define( ‘YOUR_PLUGIN_VERSION’, ‘1.0.0’ ); register_activation_hook( __FILE__, ‘your_plugin_activation_function’ ); function your_plugin_activation_function() { // Do activation tasks here. your_install_function(); your_upgrade_migration_function(); } Run your install script. function your_install_function() { // Set the current version of the plugin in the db. … Read more

Using an Image Slider twice on the same page

My approach (take it as such) would be simply generating a unique ID which will differentiate each slider. That’s anyway a good practice when the same functionality can potentially be displayed multiple times on the same page. First, find a way to generate an incremental $id to use in your template. Maybe an instanciation ID… … Read more

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”]

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’