If I understand you correctly, your dummy_data.json
file is placed in the root directory of your page (the same directory where index.php and wp-config.php are placed), right?
In that case you can easily access that file passing this path: 'dummy_data.json'
only when your code is run from index.php file.
But AJAX calls are fun from wp-admin/admin-ajax.php
file. So when you try to open 'dummy_data.json'
during ajax action, your code will try to open file called dummy_data.json placed in wp-admin directory – and there is no such file.
You can solve it by adding ABSPATH to the path:
get_file_contents( ABSPATH . '/dummy_data.json' );
Related Posts:
- Custom query to get post names beginning with a digit
- Custom Yoast Breadcrumbs URL
- Real time Duplicate title check
- How to check from which page the user is coming to the current page?
- Insert code when users come from an specific referer
- Adjust the results quantity for Search Results page pagination
- CSS saved & enqueued, but wordpress doesn’t load css text, only file
- Execute only on a certain page
- Audio tags around Mp3 URL in content
- Add a Custom Class to Admin Menus
- Type hinting and void return question
- login wp impossible
- Replace comment avatars and links at the same time
- How to display recent posts on home page with custom HTML
- How do I add text in a shortcode?
- How to display php source code inside a post using visual editor?
- Stumped – Ajax Response Returns 0
- Upload Image in a WordPress page using PHP
- Get Custom URL For Custom Taxonomy
- How to add custom post meta to default blog post?
- Shortcode content filter?
- Show full posts in archive
- I want to select the from values from database in WordPress? [closed]
- populate form fields in a loop with ajax
- Error in custom php function doesn’t exist
- Paypal form integration with wordpress registration form without plugin [closed]
- Contact form won’t submit
- How can I hide that I Use WordPress (with W3 Total Cache)
- Can anyone offer any help with this function?
- JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
- Changing the_posts_navigation() html output
- Override a function defined in wp-includes/comment-template.php
- User register hook is not working in woocomerce register form
- Show meta box only for default page template
- Display related posts without a plugin
- load ajax using admin-ajax.php
- Create a WordPress shortcode using PHP [duplicate]
- How can i count the post added in relationship field, theme display
- Custom meta box values are not getting saved for my custom post type
- locale filter function running multiple times
- How do I get the content excerpt of the recent post?
- Save Custom CSS file in the upload folder dynamically?
- Simple AJAX notification when the new post is added to the database
- How to include custom PHP file both in header and footer files
- Send notification email to admin for every new post published
- Retrieve Json data and create multiple pages with it
- Get css class of menu item in custom menu structure
- Adding an interior ‘hero’ area with some added php title customization
- How to check if a category has a parent and child categories?
- Meta boxes only displayed when editing normal (default wp post_type) posts
- Accessing Global Vars & Functions in custom php page
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Limit ‘contributers’ abilities in WordPress
- Load Javascript for a widget WordPress
- how to get sentence values from wordpress shortcode parameter?
- Disable send password change email to user wordpress
- For some time, some of my pages do not display the content anymore. Any idea where this could be coming from?
- Links to previous/next month archives
- Workaround for og:image unsupported webp image type, Yoast SEO?
- WordPress get last inserted user id
- How to populate a Gutenberg select field SelectControl with option value from PHP array
- How can i avoid duplicate same post in wp?
- Warning: Use of undefined constant all – assumed ‘all’ (this will throw an Error in a future version of PHP) in C:\Users\…….. on line 6
- Time Stamp In A WordPress Post Title That Does Not Keep Refreshing
- AJAX and custom pages
- Custom meta box is not displaying value showing tag as empty
- Get x numbers of a woocommerce category products using Wp_Query
- How does one make a URL return dynamic JSON with custom Content Type?
- custom-header not working
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- Proper use of Output Buffer for a whole php clas
- How do I make comment-reply-button with that takes to comment reply form on click
- Allow user to choose header style
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- missing admin bar and widget in a template
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- How to load WP_Editor JS files manually (with AJAX)?
- My own theme’s custom widget areas are not working
- Not able to add new item in wordpress home page
- How to apply filter
- Allow BBPress participant role to trash topics
- views How to load javascript on custom page template?
- How to find the function which is outputting Array
- Contact form field in wordpress menu
- Manipulate database of WordPress site with my own scripts
- How can I include a file related to blog URL? Nothing seems to work
- How Can I Center the Logo in the Navigation Menu? [closed]
- Where are Sessions are being started? [closed]
- Get the current page in a call back function
- PHP Use Declared array Variable inside already Declared Array
- How to create and add js and css file when server is not on my PC?
- Object of class WP_Post could not be converted to string while trying to console.log wp_get_nav_menu_items
- Check radio get value to array
- Running a php code after User clicks a button? [closed]
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- How to create shortcode of this PHP code
- Edit Error Page style
- PHP $_SESSION array – only showing current index
- How can I use AJAX in child theme template?