Get all the URLs of the pages that uses a specific shortcode

Solution that I’ve found: $pages = get_pages(); $pattern = get_shortcode_regex(); foreach($pages as $page) { if ( preg_match_all( “https://wordpress.stackexchange.com/”. $pattern .’/s’, $page->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( ‘my_shortcode’, $matches[2] ) ) { echo $page->post_title . <br />; } }

Native gallery custom html output

Is this what your looking for, here? get_post_gallery_images(). This is the example for that page. add_filter( ‘the_content’, ‘wpdocs_show_gallery_image_urls’ ); /** * Show image URLs below the content */ function wpdocs_show_gallery_image_urls( $content ) { global $post; // Only do this on singular items if( ! is_singular() ) return $content; // Make sure the post has a … Read more

How can i access woocommerce order variables inside shortcode?

WooCommerce Email template already has access to $order variable. You simply need to add it to shortcode atts, like this do_shortcode(‘[sample_test name=”additional_gift_msg” order_id=’ . $order->get_id() . ‘]’); Then in the shortcode callback: function th_email_shortcode_handler( $atts ) { // get the $order_id $order_id = $atts[‘order_id’]; // create the order object if needed $order = new WC_Order( … Read more

Run shortcode in custom script in wp_head if post type is CPT ‘Jobs’

You shouldn’t do it in a shortcode, you should enqueue this particular JavaScript file only for the page you want. Place something like this in your functions.php: function my_custom_scripts() { if( is_singular(‘job’) ){ wp_enqueue_script(‘jobpostingschema’, get_stylesheet_directory_uri() . ‘/js/jobpostingschema.js’, array(), ”, false); } } add_action(‘wp_enqueue_scripts’, ‘my_custom_scripts’);

Short code inside the page not working in WordPress

Without knowing further details of your specific installation: Make sure you are actually previewing live on the web in a browser to see if the short-code actually is working. Make sure you have spelled the short-code correctly, and have the correct syntax. (See theme’s documentation.) If the short-code requires some special JavaScript library, often other … Read more

Shortcode not working – quotes seems strange

You need to use “, and not ”. They’re different characters. You can end up with the latter if you’ve copied them from a forum or blog post where the writer’s CMS converts ” to ‘fancy quotes’. Just delete the quote marks and type them again yourself, or if that doesn’t work, just copy them … Read more

Shortcode to pull posts

UPDATE Turns out the issue was with the first page of posts. I needed to account for page 1 when calling the ajax load more. Since this is a shortcode and not a template my query vars were not passing along to the ajax call. I resolved the issue by passing the page as a … Read more

Cant display an image via PHP in wordpress

I think that you need echo the image, try this: <php $image = wp_get_attachment_image_src( $post_thumbnail_id ); //echo( $image[0] ); ?> <img src=”https://wordpress.stackexchange.com/questions/319794/<?php echo $image[0]; ?>” alt=””>

How can I pass a shortcode value to the head in wordpress functions.php

Shortcodes, as I understand them, are to be used inside content of pages/posts, and (with 4.9) widgets. They aren’t supported inside other spots on the page, only in the page/post/widget content. From the Codex: https://codex.wordpress.org/Shortcode [WP] only expands the shortcodes within the content of a Post, Page, or custom post type. But I don’t think … Read more