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
- Remove slug from custom post type post URLs
- How to sort the admin area of a WordPress custom post type by a custom field
- How to create a custom post type without letting WordPress assign a URL
- Displaying Custom Post Types In “At A Glance” Meta Box
- How do I require authorization / login to view a specific set of posts / pages?
- How can I include custom post types on a tag page?
- How to Make an admin_notices Message That Disappears Once the User Leaves That Particular Page?
- Custom Post Type Rewrite Rule for Author & Paging?
- How to display category information from a custom post
- Unable to save custom taxonomy terms in a custom-built metabox
- Custom Post Type: Set post_title equal to a custom post type field
- I can’t set meta_key in my custom post type query
- custom sortable column
- How to embed form data within the ‘Add new post’
- Getting a custom post type image using ‘get_post_custom’
- How to noindex nofollow custom post type?
- How to add custom post types to normal category pages
- How to create custom boxes with text inside?
- Displaying the first category from a custom taxonomy with get_the_terms
- Get term name and term parent into custom post type permalink
- I want to create custom post in which user can share files like PDF & DOCx
- Update postmeta Parent when post_status child change
- Hierarchical permalinks for custom post type and taxonomy
- How do I control the output of a custom post type in the loop?
- Pagination broken by naming conflict between CPT and Page
- Pagination Error : Duplicate argument being outputted
- Assign category a default post type
- Specify a particular page to list all custom types
- WordPress Custom URLs
- Fancybox loading small white square
- Add admin script to several post types
- Add Class After 4th Post
- Setup page template array in a custom post type
- Display future posts in search
- Custom Taxonomy and Categories
- Excluded Custom Taxonomy Term Posts Displaying in loop
- I want to show post details based on roles user login
- Listing all custom posts having a specific taxonomy whatever the terms
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- Create a Hierarchical List of Custom Taxonomies AND Posts
- Taxonomy template file not working with a taxonomy that contains a slash
- How might I change the destination of a link?
- Custom Taxonomy page redirecting to 404 page
- Sort by date, then by time
- Can the wp_posts table have the same slug (post_name) in multiple statuses (post_status)?
- Imported Content Doesnt Show Up On Frontend
- Prevent author role from editing others posts
- CPT archive as home page
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Add category slug as class attribute in a link array
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- Rich Custom Field for Custom Post type not saving
- Custom Post Type – Rewrite slug [duplicate]
- How to show selected value in dropdowm menu
- Post content stays the same but permalink changes ?
- Post types disappeared
- Gravity Forms Post method [closed]
- Getting ACF relationship field information
- How to make a non-public post on wordpress approval?
- Quering array of post types & pagination. Articles are repeating sometimes on different pages