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

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

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.

Get Posts shortcode plugin and meta_query?

Besides the plugin not being updated, this will not work because the meta_query arg is evaluated as a string: array(3) { [“post_type”] => string(7) “project” [“meta_query”] => string(96) “array(array(‘key’ => ‘state’, ‘value’ => ‘Completed’),array(‘key’ => ‘year’,’value’ => ‘2006’))” [“suppress_filters”] => string(5) “false” } I suggest you make a custom page template, where you would directly … Read more

shortcode causing the_content() to return blank?

Fixed my problem! I was finally able to find some info out there in the vast internet. Visit this site for info on fixing this odd issue. Over all using the remove_filter(‘the_content’,’wpautop’); did the trick. http://www.undermyhat.org/blog/2009/07/sudden-empty-blank-page-for-large-posts-with-wordpress/

Shortcode content not displaying on Home page

Is the homepage pulling in the_excerpt() ? If so you will have to add this to your functions.php add_filter(‘the_excerpt’, ‘do_shortcode’); This will work if you are putting in manual excerpt. It shouldn’t be stripping out the shortcode if you are using the_content() in your homepage template.

passing parameters to do action from shortcode to wp_footer

Use a class, store the value you need in the footer in a member variable. Sample code, not tested: add_shortcode( ‘tooltip’, array ( ‘WPSE_69605_Tooltip’, ‘shortcode_callback’ ) ); class WPSE_69605_Tooltip { protected static $var=””; public static function shortcode_callback( $atts, $content=”” ) { self::$var=”foo”; add_action( ‘wp_footer’, array ( __CLASS__, ‘footer’ ) ); } public static function footer() … Read more

WordPress display image link in shortcode

You can reuse the $content parameter: function image_code($atts, $content = null) { $url = esc_url( $content ); return “<a href=”https://wordpress.stackexchange.com/questions/78252/$url”><img src=”https://wordpress.stackexchange.com/questions/78252/$url” class=”user-imgs” /></a>”; } Or pass the URL as parameter in case you want to use a different URL: function image_code($atts, $content = null) { $args = shortcode_atts( array( ‘url’ => FALSE ), $atts ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)