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
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- wp_insert_post generates endless posts
- Remove standard meta boxes from custom taxonomy
- How to create shortcode to display custom field value on a custom post type
- How to enable shortcodes in a custom post type?
- What’s the difference between same wp functions get_posts(); functions in different form?
- I did group my search results by post type, but how can i give each of them its own order?
- Dequeue scripts and styles only for specific custom post type
- Get custom fields from a custom post type with a shortcode
- Shortcode for display posts in wp-editor
- Function to display custom post type on front page makes menu items dissapear
- Display Recently Added Custom Post Types with Custom Taxonomy Shortcode
- custom post type not showing in menu
- Show category ID on custom post type
- How to customize a permalink (URL) structure?
- Custom Post Type with Templates using Meta Boxes?
- Can I list a custom post type within another custom post type in the admin area?
- Change custom post type slug from plugin options
- Get custom post type list for every category shortcode
- Can’t edit custom post type
- Set URL link to featured image of custom post type
- Change CPT archive title
- AJAX load more for different custom post type loops
- PHP variable not regenerating when publishing multiple posts at the same time
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- How to target a specific custom post type post and its all children and grandchildren?
- Featured image overlay when changing post status
- get_post_meta not working on publishing
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Display featured image from one CPT within another CPT query
- Query taxonomy of taxonomy of custom post type
- Best way to style first post differently?
- How to make custom posts types display when published for the future
- How to rewrite url for any specific taxonomy?
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- 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
- CPT archive admin menu label
- Anon function and add_meta_box
- Form action/link to render a plugin in WordPress front-end
- custom post type category count shortcode
- Display Child Pages of Custom Post Type Parent Page
- Hide a widget inside a div on specific type of post
- Shortcode not working with post counter
- Shortcode to display Staff post type based on Location post type and Specialty post type
- Changing default ‘posts’ parameters with register_post_type_args
- wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query
- Shortcode for CPT post content in a page
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Cannot save CPT meta box
- Allow users to create posts without logging in?
- Next Post links not working in custom post type shortcode
- How to change permalink to include custom post type
- Foreach inside shortcode not working as planned
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Add term to custom post type on draft
- How to assign classes to all elements?
- next_/previous_post_link() `in_same_category` appears to fail when true
- Want to be able to sign up subscribers as authors
- Load scripts based on post type
- Different Category system needed for the Custom Post Type
- Global custom meta box
- Redirect to another page using contact form 7? [closed]
- Template not working for the custom Post type
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- Can a shortcode included in post content add styles to the ?
- How to retrieve category of a post in have_post loop?
- categories should be available across all custom post types
- Warning: Invalid argument supplied for foreach() in post.php [closed]
- Featured Image field not appearing in Custom post type
- Post-thumbnail only for specific post-types?
- custom post type metaboxes not saving
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Enable taxonomies by post type in an array of CPTs
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Checking if looped item has a parent inside a shortcode
- PHP question: how to combine syntax?
- Using wp_localize_script to get data from cpt and pass it to maplace-js locations
- Loop increase number
- custom post for slider
- get_post_meta is not working inside shortcode
- the_post() is printing titles in page footer
- ACF in wordpress