You need to load WordPress before using wp functions, use this just after the <?php
tag:
require( '<<DIR>>/wp-load.php' );
where <<DIR>>
is the path to the main wordpress folder (in your case something like ../../../
, add double dots as needed to navigate up the plugins and wp-content hierarchy
NOTE: direct linking outside you control zone (i.e. you plugin directory) is not the best thing to do, as it might break in the future. What can you do is write the code in the plugin file(s), wrap it in a function and hook it to a wordpress action (like an ajax form action, see here )
Related Posts:
- TCPDF get_post_meta outside the loop
- Attaching a pdf to Contact Form 7 e-mail via functions.php [closed]
- How do you use WP slugs for PDF files / media?
- PDF file randomly breaks upon upload
- PhantomJS with wordpress
- Attach and retrive multiple pdf files to post or page
- Search through documents folder
- How To: Simple domPDF Example
- The correct method to pass query vars in AJAX using ajaxurl
- Display user’s total comment count outside The Loop
- Getting the action’s tag name within the action
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- How to add query vars with paginated URLs?
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- wordpress separate registration for different roles
- How to get user by display_name with WP_User_Query
- Changing Link Attributes for Wp_Link_Pages
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- How to change
- Get only the grandchildren, not the direct children of page/current page?
- WordPress 2.8.5 & ‘Responsive Twenty Ten’ – error
- wordpress inserting posts programatically through a url
- WordPress Ajax Custom Query – High CPU LOAD
- How does WooCommerce ensure that a product doesn’t run out of stock during payment? [closed]
- Can I change a variable in a content part while calling it?
- How do you target virtual pages in code?
- Must Use Plugin Causing Query Error
- action hook wp_head higher priority as all other plugins/hooks
- Shortcode return function with link href inside PHP
- PHP get the first post separately from array returned by wpdb->get_results()
- How to add just one specific page to widget without plugin?
- How to use transient in this code for related post?
- Why is $_REQUEST an empty array in admin-ajax.php?
- Change behavior of the tag
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Woocommerce hook run after an Order been created through REST API
- How to remove ?wp-mce-4103-20162941
- How to pre populate a form field with a link of a current user’s author profile?
- wp_head function not outputting
- Using the_excerpt() on a page
- PHP echo inside javascript
- Value prints outside of the echo
- get_total () returns 0 – woocommerce [closed]
- php include not working in custom page
- If ‘editor’ is empty, then
- php redirect with custom user roles set and working but redirect not working for when users are logged in
- Display Yoast meta-description `wpseo_desc` within loop of categories and fail silently if no data is set [closed]
- Does get_post function counts as view?
- Get ACF options field in PHP acting as CSS
- Permalinks are not working in WordPress in digitalocean
- Creating black and white copy of an image [closed]
- PHP code inside Shortcode
- Amend theme php to include certain category in header
- add category to posts with tag wordpress
- Missing a text-domain esc_attr_e
- Get all posts from categories
- How to insert data from metabox to custom table
- How to Generate a list of Most Commented post?
- Updating From Mobile App – Exposing Site to Hacking
- call adminbar greeting in other place
- is user member of a group, show them categories [closed]
- How to add ASCII symbol after each recent post [closed]
- WP_LINK_PAGES Generating Unnecessary Tag
- Why is home page content not displaying with this rewrite rule?
- Add class to ul and li in wp_na
- How can i programmatically change the SKU of a product based on product variation?
- Export post data with xml to other site using php soap
- Execute PHP code only with specific user role
- Repeat a function with 24hrs gap for n number of days
- How to serve WordPress folder over subdomain?
- PHP function for horizontal Woocommerce thumbnails and badges
- How to call my PHP function with AJAX ? wp_query
- How to route root path / to /xyz in nginx?
- Get the same SKU from woocommerce itself for simple and variable products
- Show sidebar only to author of post
- The style.php file inside theme-engine folder has other content on FTP
- how to add custom select field to wordpress edit page
- How to update post content of all posts with tag?
- Make WooCommerce product categories only show images on homepage
- How to Change Site Elements based on referring URL
- WP post meta – for loop inside for loop
- Insert data from form to database
- My search results are only showing 5 posts?
- WP_query meta_query slow with OR and DATES
- WordPress Query Crashes Browser
- Matching multi user
- customizer live preview layout picker
- WordPress using get_term to retreive slug not working as expected
- auto metakey value on post tile
- On a custom template, should I use wp_footer? [duplicate]
- Front end post submissions do not get submitted in the category
- How to pass parameter that ends up being part of a class name with wordpress shortcode
- how to check for wordpress Query errors
- calling a function from a class in your template
- WordPress and magic quotes
- Dynamically pull the correct email address from a match
- Troubleshooting “loopback requests that take too long”
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- Order woo products, but first products must be with acf fields
- links Slick jS library using wp_enqueue_scripts not pulling