Show form per shortcode

Use add_shortcode in your plugin or theme or, if you don’t want to add a plugin or modify the theme, use Code Snippets plugin. Your code will look like this: add_shortcode( “your-awesome-unique-shortcode”, “wpse376442_your_awesome_shortcode_callback”); function wpse376442_your_awesome_shortcode_callback($atts, $content, $shortcode_tag) { $user_id = get_current_user_id(); $balance = mycred_get_users_balance( $user_id ); $echo = “Current Balance: “.$balance.”<br><br>”; if ($_POST && $_SERVER[“REQUEST_METHOD”] … Read more

Are Shortcode Attributes Always Passed As Strings?

Yes, shortcode attributes are always strings. WordPress has no way of knowing the intended type of each attribute, and the values are ultimately pulled from an HTML string, after all. If you need $id to be an integer, just do this: $args = ( shortcode_atts( array(‘id’ => ”), $atts ) ); $id = (int) $args[‘id’]; … Read more

Getting Page Content Using Shortcode

First, I will add here 3 resources for learning most of the things you need about shortcodes: Official WP Docs A good article Another article that I wrote The idea is that you don’t echo the content in your shortcode, but you return it so that WordPress can only print it where it is needed. … Read more