WordPress Code Standards and Working $link Parameters In Shortcode

how to make this shortcode [parent-child] working with link=false , and no extract in shortcode. You can never pass boolean value as shortcode parameter, rather it should be treated as string. Your comparison over the param link value false should be used as ‘false’ (string). add_shortcode( ‘parent-child’, ‘taxonomy_hierarchy’ ); function taxonomy_hierarchy( $atts ){ // Don’t … Read more

Display a post by ID attribute with shortcode

Try $HTML instead of $html Linux based systems are case-sensitive … function post_banner_shortcode($atts) { $atts = shortcode_atts( array( ‘id’ => ” ), $atts ); $post_id = $atts[‘id’]; $HTML = ‘<div class=”postbanner”>’; $HTML .= ‘<div class=”pb-thumb”>’ . get_the_post_thumbnail($post_id, ‘medium’) . ‘</div>’; $HTML .= ‘<div class=”pb-ttl-txt”>’; $HTML .= ‘<h4>’ . get_the_title($post_id) . ‘</h4>’; $HTML .= ‘<p>’ . … Read more

How to change page title (from a plugin) in twentytwentyone theme

You can do it like so: function filterDocumentTitle(string $title): string { // don’t change title on admin pages or when global $post is not loaded if (is_admin() || get_the_ID() === false) { return $title; } // don’t change title if shortcode is not present in content if (!has_shortcode(get_the_content(), ‘caption’)) { return $title; } return ‘special … Read more

Bulk converting shortcodes to blocks with embeds

Ultimately, I solved the problem by exporting the wp_posts table from the database and doing a regex search along the lines of ‘([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]’, ‘[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9])’, ‘(.*?)\[soundcloud url=\\”http://api\.soundcloud\.com/tracks/(.*?)\\” params=\\”auto_play=false&show_artwork=false&color=ff7700&show_playcount=false\\” width=\\”100%\\” height=\\”180\\” iframe=\\”true\\” /] and replacing it with ‘\1’, ‘<!– wp:paragraph –>\2<!– /wp:paragraph –><!– wp:embed \{“url”:”http://api.soundcloud\.com/tracks/\3″,”type”:”rich”,”providerNameSlug”:”soundcloud”,”responsive”:true\} –> <figure class=”wp-block-embed is-type-rich is-provider-soundcloud wp-block-embed-soundcloud”><div class=”wp-block-embed__wrapper”> http://api\.soundcloud\.com/tracks/\3 </div></figure> <!– … Read more

Pass variable to nested shortcode

I assume you just pass the content of ct_training_group to another call of do_shortcode()? You can’t pass extra parameters to it, so if you don’t want to use global state variables, you could always replace the current shortcode handler for ct_training with one that doesn’t add the extra <ul>. It seems there is no cache … Read more

How do I combine my shortcodes?

Change st_paragraph() to this: function st_paragraph( $atts, $content = null ) { return ‘<p class=”first-paragraph”>’.do_shortcode($content).'</p>’; } See Codex documentation.

Shortcode displays always first. Once again

Yes, look at the widget() method in your MyWidget class. Does it echo? Most likely it does, because that’s how widgets are normally written. In fact, I’d be surprised to see a widget that didn’t echo output in its widget() method. And when you call the_widget(), it fetches an instance of the widget you ask … Read more