Pass a PHP variable to another file

The WordPress template functions don’t support passing variables (to my knowledge) by default, so you need to write your own function. For example like this, // functions.php function my_template_include_with_variables( string $path=””, $data = null ) { $file = get_template_directory() . “https://wordpress.stackexchange.com/” . $path . ‘.php’; if ( $path && file_exists( $file ) ) { // … Read more

Edit tag cloud widget number

Add the following to your theme’s function.php. Default values are shown below, except changing ‘number’ from 45 to 15. Only the changed values need to be included, so you can either leave the default values or remove/comment out those lines. For WordPress Tag Cloud widget: function custom_tag_cloud_widget() { $args = array( ‘smallest’ => 8, ‘largest’ … Read more

Include files in functions.php

Including a file inside a subdirectory is the same as any other as long as you know the path to the file. Since it’s possible to move the ‘wp-content’ directory, don’t pass that part of the path to the require statement; instead, use the WP_CONTENT_DIR constant. require_once WP_CONTENT_DIR . ‘/new-directory/my-file.php’; Also, you can leave out … Read more

Woocommerce get selected shipping zone id for the current user

The problem is that WC_Cart get_shipping_packages() method gives an array of shipping packages and the function wc_get_shipping_zone( $package ) expect to have as argument a unique package. So you need to get only one package, using for example php reset() function like: // Get cart shipping packages $shipping_packages = WC()->cart->get_shipping_packages(); // Get the WC_Shipping_Zones instance … Read more

Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?

The reusable block is registered with the core/block name. I tried to add it to the allowed blocks in the allowed_block_types filter, here’s an example: add_filter( ‘allowed_block_types’, ‘wpse324908_allowed_block_types’, 10, 2 ); function wpse324908_allowed_block_types( $allowed_blocks, $post ) { $allowed_blocks = array( ‘core/block’, // <– Include to show reusable blocks in the block inserter. ‘core/image’, ‘core/paragraph’, ); … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş