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
- Front end registration/login & publish/update 1 custom post
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Display custom post type taxonomy and month
- Genesis filterable portfolio isotope [closed]
- Filter posts by tax (dropdown) and meta value
- WordPress admin for a custom post, hide/collapse the main “title” and “description” boxes
- Use custom post type taxonomy between cpt slug and name
- Building Link List for Custom Tax
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Canonicalization + Custom Post Types not working as expected
- Custom post type is_singular condtional not working when managing sidebar display
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Delete old thumbnail when updating new
- get_the_post_navigation not working
- Display ACF object field data using Elementor Custom Query
- Changing to different post type maintains the redirection?
- Sortable admin columns ordering from custom fields isn’t combine com search and Dropdown filter
- Calling custom taxonomies
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Limit taxonomy terms added to a custom post type
- I want to understand plugin implementation of custom posts / taxonomies / metaboxes
- Issue displaying multiple TinyMCE editors with WPAlchemy
- Default WordPress Query for a Specific Custom Post Type URL
- Custom order of CPT posts by title, in wp-admin area by default
- Sort ACF by custom taxonomy
- Custom post type with custom parent prefix slug
- Is it possible to use a post name in a custom post slug?
- How do I add the “orange counter” next to a Custom Post Type?
- Custom slugs with dates & IDs on Custom Post Type
- using jetbooking for multiple custom post types
- Custom post type pagination conflict result in 404
- Dynamically count the number of custom post types associated to a custom taxonomy
- Add post id to url instead of WordPress default -2 suffix
- How to consume external API from WordPress post editor and display the response data in the custom field?
- Taxonomy Archive URL + Template
- Custom post type pagination not working in index.php file
- CPT without slug after domain mapping
- Can’t expose custom field to REST API
- Custom Post Type posts not getting picked up in archive widgets
- Quering a post object based on another related post object
- Custom Post Type Pagination Showing 404 On archive pages
- Display category name and title of last post (in custom post type)
- Custom PHP Template in Twenty Twenty-Four
- Trying to add CPT to menu automatically
- ACF Pro simple Business Directory – Requesting assistance with created Templates and associated Functions.php Coding
- Custom Block: Adding “Post Type” dropdown to Sidebar Settings
- Change formatting of Date parameter on custom post type
- How do I get an intermediary page between 2 custom post types?
- Advanced Custom Fields Custom Post Types Heirarchy
- Сustom posts are displayed in the wrong menus
- Many CPT is conflicting of the custom date
- How to add random prefix (based on related page slug) to custom post type?
- How does WordPress manage to differentiate between post and page URLs without a distinct base, and how can I replicate this functionality?
- How to generate programmatically a post which displays a chunk of content from two different posts belonging to two different Custom Post Types?
- Allowing a CPT post to be edited by a single user role