MathJax inside shortcode

You cant call a shortcode inside a shortcode they do not automatically nest, you need to use do_shortcode($content) like this (i am assuming the name of your shortcode): function alert_shortcode( $atts, $content = null ) { return ‘<div class=”alert alert-‘ . $atts[‘type’] . ‘” role=”alert”><p class=”alert-title”>’ . $atts[‘title’] . ‘</p>’ . do_shortcode($content) . ‘</div>’; }

Plugin CSS not enqueing

If you want to add inline CSS, use wp_add_inline_style(). <?php /** * Plugin Name: WPSE 257470 * Description: WordPress StackExchange question 257470 * Plugin URI: https://wordpress.stackexchange.com/questions/257470/ * Author: Nathan Johnson * Licence: GPL2+ * Licence URI: https://www.gnu.org/licenses/gpl-2.0.en.html */ //* Don’t access this file directly defined( ‘ABSPATH’ ) or die(); if( ! class_exists( ‘wpse_257470’ ) ): … Read more

Why is file_get_contents returning page source?

Aha, I figured it out! You have to use wp_remote_get(). I’m not exactly sure why at this point, but here’s what the code looks like: function display_csv_data_func( $atts ) { $file_path = “http://example.com/something/file.csv”; $response = wp_remote_get($file_path); $response_body = wp_remote_retrieve_body($response); return “<script>alert(‘” . $response_body . “‘);</script>”; } add_shortcode( ‘display_csv_data’, ‘display_csv_data_func’ );

What is the best way to embed an JS App in a WordPress Page?

Make the public page a template and then target it with is_page_template() How to create a page template. in your functions.php something like: function wp_25271() { if (is_page_template(‘page-public.php’)) { wp_enqueue_script(‘bootcards’, ‘https://cdnjs.cloudflare.com/ajax/libs/bootcards/1.1.2/fonts/icomoon.svg’, array(‘jquery’), ”, true); } add_action(‘wp_enqueue_scripts’, ‘wp_25271’);

Creating shortcode with parameter

Here’s an example of a [color] shortcode. If a parameter is specified, we assume (but verify) that it is a color. $content is then wrapped in <span> tags and the color is applied using inline styles. The color can be passed as a named color or hex color. Hex colors in 3 or six digits … Read more