shortcode tags not working in do_shortcode

You maybe need to return the output at the end of the function, then do’t forget to echo the do_shortcode(). function shortcodename_function($atts) { $pairs = array( ‘title’ => ‘bananas’ ); $a = shortcode_atts($pairs, $atts); return $a[‘title’]; } echo do_shortcode(‘[shortcodename title=”monkeys”]’); Of course you can echo directly in the function, but it’s a bad pratice for … Read more

Make plugin php file called directly aware of WordPress?

You can’t load plugin files directly, you need to target either a front-end or admin URL that bootstraps WordPress. An easy way to do this is the admin_post_(action) action: add_action( ‘admin_post_add_foobar’, ‘prefix_admin_add_foobar’ ); function prefix_admin_add_foobar() { // your code here } You can then POST your data to admin_url( ‘admin-post.php’ ) and set action to … Read more