How can I put a wp_redirect into a shortcode?

Shortcode functions are only called when the content of the visual editor is processed and displayed, so nothing in your shortcode function will run early enough. Have a look at the has_shortcode function. If you hook in early enough to send headers and late enough for the query to be set up you can check … Read more

How do I use Shortcodes inside of HTML tags?

Hope this helps someone: Instead of doing this: <a href=”https://example.com/folder/edit.php?action=someaction&id=[foocode parameter=”value”]&edittoken=[foocode parameter=”othervalue”]”>linktext</a> You can do this: [foocode parameter1=value parameter2=othervalue] and then do this: add_shortcode( ‘foocode’, ‘prefix_foocode’ ); function prefix_foocode( $atts ) { // Normalize $atts, set defaults and do whatever you want with $atts. $html=”<a href=”https://example.com/folder/edit.php?action=someaction&id=” . $atts[‘parameter1′] .’&edittoken=’ . $atts[‘parameter2’] . ‘”>linktext</a>’; return $html; … Read more

Combining shortcode and get_template_part

Try this function get_products($atts) { ob_start(); get_template_part(‘block-products-inline’); return ob_get_clean(); } add_shortcode(‘products’, ‘get_products’); Little explanation php just outputs your content right away when its see print statement. What we do here is, we are holding all the output in buffer and not giving it in print until the whole things finish. then we are returning the … Read more

How to display the site name in a WordPress page, or post

No, there is no core shortcode for this. The site name is available as an option, in facts get_option(‘blogname’) returns the blog name. Moreover, get_bloginfo(‘name’) / bloginfo(‘name’) can be used to get / echo the site name. Of course, you can’t use that functions as a shortcode by default, so if you want to obtain … Read more

Remove specific shortcode from get_the_content()

If you want exactly this shortcode: to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that. Here are two such examples: Example #1 /** * Let the shortcode output “almost” nothing (just a single space) for specific attributes */ add_filter( ‘wp_video_shortcode_override’, function ( $output, $attr, $content, $instance ) … Read more

Is there a way to add another row to the tinyMCE kitchen sink toggle?

Yes! Use the mce_buttons_2 filter to add buttons to the second row. Use the mce_buttons_3 filter to add buttons to the third row. Here’s an example of what I use: function mytheme_mce_buttons_row_3($buttons) { $buttons[] = ‘fontselect’; $buttons[] = ‘fontsizeselect’; $buttons[] = ‘code’; $buttons[] = ‘sup’; $buttons[] = ‘sub’; $buttons[] = ‘backcolor’; $buttons[] = ‘separator’; $buttons[] … Read more

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