How to pass text input data to shortcode

You would need to do this in the shortcode function for [api_request]. Here’s a potential answer with a ternary that would check if the $_POST value exists, if so, sanitize and use it, otherwise use the value passed in the shortcode: $q = ( isset( $_POST[‘q’] ) ) ? sanitize_text_field( $_POST[‘q’] ) ? $atts[‘q’]; This … Read more

Elements positioning in a custom block

You would need a combination of JavaScript for the custom block, and CSS to make the H1 span across both columns. The JavaScript would be like this: registerBlockType(‘my-plugin/two-columns’, { title: ‘Two Columns’, icon: ‘screenoptions’, category: ‘common’, attributes: { title: { type: ‘string’, }, imageUrl: { type: ‘string’, }, }, edit({ attributes, setAttributes }) { const … Read more

Set new url from custom post field

It sounds like the custom_url_posts_event function you’ve written is not being called by WordPress when generating the permalink for a post. This may be because the add_filter call is not properly hooked into WordPress or because the custom_url_posts_event function is not registered correctly with the post_type_link filter. To fix this, you should first ensure that … Read more

How to Create Custom Route to a page in WordPress

To set up a custom route in WordPress, you can use the add_rewrite_rule() function. This function allows you to specify a regular expression (regex) pattern for matching URLs and a corresponding rewrite rule for redirecting matching URLs to the desired destination. Below is an example of how you could use this function to create a … Read more

Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo

The examples you’ve seen are out of date. From WordPress 4.5, released in 2016, the proper way to support a custom logo was to register support for the Custom Logo feature in your theme. That link has the full documentation, but the short version is that you use this code to enable the standard logo … Read more