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

Create WordPress shortcode with php code inside

Creating a shortcode is fairly simple, it only needs a shortcode name and maybe some arguments. Here is a simple one for you: add_shortcode(‘my-shortcode’,’my_shortcode_function’); function my_shortcode_function(){ return ‘<div id=”search-nacionalidad”><p class=”‘. get_field(‘nacionalidad’).’ noselect” title=”‘.get_field(‘nacionalidad’).'” alt=”‘. get_field(‘nacionalidad’).'”>’.get_field(‘nacionalidad’).'</p></div>’; } Now, using [my-shortcode] exactly does what your code does. However I’m not sure how do you use this, whether … Read more

Responsive embed for the video shortcode

You could create a new callback for the embed_oembed_html filter and target the third input argument, the oembed $url. Then you could e.g. create boolean helper functions like (untested): function is_oembed_from_video_specific_hosts_wpse274552( $url ) { return in_array( parse_url( $url, PHP_URL_HOST ), [ ‘youtube.com’, ‘youtu.be’, ‘vimeo.com’, // … etc ], true ); } or a more detailed … Read more

Is my code is right to make image shortcode

Your code is right just need to change $atts variable. // if you want to add image, alt attribute on shortcode statically $atts = shortcode_atts( array( ‘image_src’ => ”, ‘alt’ => ”, ‘add_img_class’ => ”, ‘id’ => ” ), $atts, ‘hero-banner’ ); // if you pass image and alt attribute dynamically $atts = shortcode_atts( array( … Read more

Append HTML Using Shortcode

First things first. You shouldn’t really use echo inside a shortcode, unless there is NO way to return the value. In your case your can simply convert it to a function that returns a value: function date_important_info(){ return display_date($date); function display_date($date){ $data = ” <div id=’my-shortcode’ style=””> <span>Date:</span> <span> {$date} </span> </div>”; return $data; } … Read more

Shortcode for display posts in wp-editor

Declaring a shortcode is as easy as using this: add_shortcode(‘jobs’, ‘callback_function’); function callback_function(){ $content=””; $args = array( ‘post_type’ => array(‘job’), ‘posts_per_page’ => 20 ); $the_query = new WP_Query( $args ); if ($the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); if ( 683 !== get_the_ID() ) { $content .= ‘<a href=”‘. get_the_permalink().'” class=”jobs”>’; } $content … Read more