Is there a way to parse shortcodes in PHP?
You can execute shortcodes using the do_shortcode() function $gallery_html = do_shortcode(”);
You can execute shortcodes using the do_shortcode() function $gallery_html = do_shortcode(”);
$value = get_theme_mod( $name, $default ); if ($value !== $default) { ?> <a href=”https://wordpress.stackexchange.com/questions/88378/<?php echo $value; ?>”>This is the link</a> <?php }
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
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
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
Here’s what worked for me: My Hostgator WordPress site was throwing the same error until I commented out the top-level .htaccess file. Like so: My website is a subdomain, so it had it’s own .htaccess, so that’s where the php version was specified (cpanel did this automatically). I didn’t have to edit wp-config.php or anything … Read more
Replace “myplugin_” with your prefix: global $wpdb; $plugin_options = $wpdb->get_results( “SELECT option_name FROM $wpdb->options WHERE option_name LIKE ‘myplugin_%'” ); foreach( $plugin_options as $option ) { delete_option( $option->option_name ); }
An error about something on line 1 that is actually on a later position means that PHP doesn’t recognize your line endings. There are three ways to encode a line ending, and PHP understands only two of them: LF, or \n, Line Feed, U+000A CR, or \r, Carriage Return, U+000D CRLF, or \r\n, the combination … Read more
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
This markup is generated on the js side of things and saved in the content of the block editor, which is why there doesn’t seem to be a native PHP function for this. However, I found a PHP method that does exactly this in an “experimental” class in the Gutenberg plugin. You can see this … Read more