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');
Related Posts:
- Post the content of a specific “Custom Post Type” post within a post using a shortcode
- How would I create a shortcode to display a custom post within a page or regular post?
- posts within custom post type all share the same content in the front-end
- Shortcode to return single custom post based on post taxonomy
- display custom portfolio tags
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- php dynamic content inside shortcode
- From CPT Custom Loop into Shortcode?
- Load custom post type with ID in a shortcode
- Modify shortcode to work with custom taxonomies and slugs
- Passing postid of Testimonial Custom Post in Shortcode Parameter
- Display custom post type with shortcode
- expire wordpress user posts
- Forcing all posts associated with a custom post type to be private
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page
- Best way to style first post differently?
- if && problems with transition_post_status
- Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template
- custom post type upcoming post and past post
- Add multiple custom post types in functions.php, but only one custom post type show in dashboard
- Beginner question: Accessing functions.php through admin web interface in order to import custom post types?
- How can i list custom post type categories?
- Recommended way to remove WP REST API returned data for custom post
- Need functionality with all post list available at edit.php
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Remove default post types on all sites except primary blog. WPMU
- Custom Post Types relationships
- Shortcode insertion in tab
- Filter categories of posts with checkboxes
- Copy custom field value to post title
- Insert HTML inside link in a walker
- Remove standard meta boxes from custom taxonomy
- What’s the difference between same wp functions get_posts(); functions in different form?
- Show category ID on custom post type
- Custom Post Type with Templates using Meta Boxes?
- Can I list a custom post type within another custom post type in the admin area?
- Set URL link to featured image of custom post type
- AJAX load more for different custom post type loops
- On update or create post redirect to current post position in list
- How to render a custom post type template with custom fields using shortcode
- create a new page from a custom post type similar to an authors page
- Cannot save CPT meta box
- Next Post links not working in custom post type shortcode
- next_/previous_post_link() `in_same_category` appears to fail when true
- Want to be able to sign up subscribers as authors
- categories should be available across all custom post types
- Warning: Invalid argument supplied for foreach() in post.php [closed]
- Post-thumbnail only for specific post-types?
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Enable taxonomies by post type in an array of CPTs
- Excerpt function for any content
- Page Template Dropdown For Custom Post Types
- Shortcode leaves no space for other elements?
- Custom shortcode works in Elementor editor but not on frontend
- Custom post type Shortcodes wordpress
- Add shortcode inside of the_content()
- providing access to post_id or post inside functions.php
- Creating shortcode id for custom post types
- post_content is stripping HTML when adding a new post? [closed]
- Custom Post Type for Shortcode Use – Prevent it display as a post (with slug)
- Twitter Product Cards
- Function to limit number of custom post types on homepage – TwentyTen
- How to display class name in this shortcode post query
- Excerpt length: get first paragraph
- Why is my custom post query shortcode only showing 1 post?
- display custom post on separate page
- Post type Echo code is repeating on homepage
- How do I output a list of a specific post type in a table?
- new post-type how do i retain the plugins on my sidebar?
- Custom Post Type Dashboard Tab not displaying any posts
- Show in an entry a Custom Post Type associated to a post
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- Create a CPT to edit Shortcodes Atts
- Assigning categories to custom post types via a front-end form; only works for native post type
- Default excerpt for parent of a custom post type
- Move to trash custom post type post after ACF Date Picker date is older than today
- Why can’t I filter my CPT shortcode by category?
- editing shortcode for custom post type within a plugin
- Custom post type shortcode with taxonomy attribute not working and no errors
- Display Custom Post Type Archive content with Shortcode
- How do I use URL to fetch all posts of a particular custom post type?
- How to assign post to category
- If thumbnail image else post title
- $_SESSION Not working after X amount of page views
- Different Configuration for the_excerpt()
- WordPress page not showing up – replaced with last 10 posts?
- Post that populates itself (almost) automatically using data from imported excel file
- How to mark posts as visited
- can’t see categories in appearance-menu-categories
- Shortcode error
- send email to all registered users when post expires
- adding a shortcode into a custom post type
- Nested loop called with shortcode duplicating the content above the main loop
- Add number in increment of one to DIV ID
- Display page and custom post title inside shortcode
- trying to display custom post type with custom taxonomy value by shortcode can’t works [closed]
- add_rewrite_rule not working with custom post type
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs