You are using the selector 'a[href="#content"]'
in jQuery but the href
attribute of the target links is #content<?php echo $i; ?>
. Try removing <?php echo $i; ?>
in the href
attribute.
If you need jQuery code recognise all <a>
elements with href
starting with the string “content” you can use the ^
modifier: jQuery('a[href^="#content"]')
. So your code will look:
jQuery('a[href^="#content"]').fancybox({
autoSize : false,
width : 600,
wrapCSS : 'inline-content'
});
Note that using $
namespace in WordPress like you are using it can cause javascript errors because in WordPress jQuery runs in noConflict mode.
Related Posts:
- How to enqueue scripts on custom post add/edit pages?
- Calculate Repeater Meta Box Input Field Values and Display Total
- How to localize value of posts
- How to create a repeatable / reusable divs in the metabox?
- Custom Scripts per page or Custom Post Type
- How do you use JavaScript to detect the homepage
- wp is not defined error using wp.media to create a custom image uploader
- WordPress Rest API only returns content when posttype has editor capability
- Open div inside a custom post-type with Fancybox
- Very simple wordpress block to display posts from an api call
- How to get the parent of a non-hierarchical custom post type being edited in Gutenberg
- Storing posts from query and accessing later via AJAX call
- Push metadata in array
- Save the post parent in a custom post type in Gutenberg
- Plugin – Combine Meta Box Input Fields into single saveble record
- JS innerhtml changing style when using AJAX
- Side effects of Script and Iframe in post
- Dynamic Custom Fields
- Multiple Frontend Filters Using Advanced Custom Fields
- Extracting Address from Custom Post via Javascript for Google Maps API
- Combine multiple getEntityRecords calls
- Custom Post Type Slick Slider “$ is not a function”
- Using wp_localize_script to get data from cpt and pass it to maplace-js locations
- Get data from PHP to JavaScript to set position of each post on front page
- Why is wp api returning old acf values?
- Weird issue where form field loses focus to previous form field even with JS disabled
- WordPress/Javascript form not working on custom post type single posts
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- How can I put content before my custom post type default pages?
- URL issue retrieving Custom Post Types using Backbone JS API
- Randomizing WordPress Custom Post Type Sorting Through Them Without Page Refresh
- How can I use javascript in specific posts without relying on a plugin?
- How to use posts as tabs in a custom page?
- Hide the update button from edit view in wordpress custom post type
- WordPress custom post type post item data – show/fetch only on click with Javascript dynamically?
- localize_script or rest api
- dynamic vue widget inside custom post
- How to make sure, that only the selected post is changing?
- Redirect sub-page URLs to parent without changing URL
- Loops running into each other
- Passing total post count to javascript
- get total post in category via ajx
- Default post showing more than intended
- Load more post with AJAX
- Post current post type to my Ajax
- Ajax load more post button not showing
- Hook to override title, image and content
- Custom template with CPT doesn’t display on frontend
- Single Template for Custom Post Type stops working after WordPress 5.4 update
- How do I get array of types associated with a taxonomy?
- Custom Post Types – Change order of menu items
- Custom template page with custom archives listing by user
- Insert Multiple Post with Same Publish Button
- post_type_link not working in gutenberg
- get_post_meta returns empty array for terms
- Copying existing posts after new post type has been added
- Publish an XML feed from a CPT with ACF fields?
- wp_insert_post generates endless posts
- Custom post type not using custom template
- Return the thumbnail meta data for getter and setter
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Cannot save Checkbox meta box value from a Custom Post Type
- Display CPT posts based on specific taxonomy
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Admin not showing all custom post type posts and views not working
- Wrong generated page_name/slug on first publish of custom post type
- Can’t change first part of URL rewrite for custom post type
- Custom Post Type template stored in plugin folder not showing in post attributes dropdown
- Get all properties of custom post type
- Restrict user to only one custom post type
- How do I get the intended post type of a revision post?
- Archive template not working for custom post type
- Remove single page for custom post type
- How to avoid manage posts screen duplicates when two plugins use the same library
- Remove standard meta boxes from custom taxonomy
- CPT Archive with core Category
- Change custom post type slugs, with category/taxonomy before post type name
- Remove post type slug of all post types from permalinks
- Custom template won’t load for a custom post type (custom permalinks used)
- How to limit post of custom post status?
- Open Custom Post Type as PDF
- Is possible add class for last post of Custom Post Type?
- how to get URL of media uploaded to WordPress via media_handle_sideload()
- Update CPT post meta with update_post_meta and cron job
- Include only recents custom posts in WP rss feed
- How to only show posts assigned to current user, only in certain post types
- Can’t query tag and post_type at the same time
- post_row_actions not working for hierarchical post type
- Move custom post menu to under plugin admin menu
- Custom meta box not saving
- How to display selected taxonomies by their parent
- How to create shortcode to display custom field value on a custom post type
- List Post Title by Last Word Then Second Last
- Using The REST API How To Pull All Custom Posts?
- Group posts by custom post type
- Subpages for Custom Post Type. Does that even exist?
- Creating select dropdown with parent-level custom post types
- Validate custom fields before save using WordPress Rest API
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Change Featured Image / Thumbnail CMS Description