The key to using WordPress outside of WordPress is include the wp-load.php file:
So your code will like:
<?php
// Include the wp-load'
include('YOUR_WP_PATH/wp-load.php');
// Update post 1 hello word
$my_post = array(
'ID' => 1,
'post_title' => 'This is the updated post title.',
'post_content' => 'This is the updated content.',
);
// Update the post into the database
wp_update_post( $my_post );
?>
It’s should work…
Once the wp-load.php file is included, the entire wealth of WordPress functions is provided to you. While the sample code above gets recent posts, you can do your own custom queries with WP_Query or get_posts().
Related Posts:
- How to store the_title() into a variable to reutrn the value, not just echo it
- Metabox repeating fields – radio buttons not saving correctly
- How can merge two arrays values in one array and save in database
- How to update single value in multi dimensional Post Meta?
- Compare two meta key values against each other inside the get_posts array?
- Looping through WP_Post Object
- Using a javascript file to access a get posts array
- WP_User_Query order by meta_key that is an array
- Generate an array of parent/child page IDs, based on parent page name
- How do I output a database option that is an array into a get_posts array?
- Can an array be used as a meta_query value?
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- List of posts by day of the week
- Check if term object is in array
- ‘orderby’ => ‘rand’ alternative for better performance?
- how can i show only the parents in owl-carousel?
- Create shortcodes within foreach loop (using array)
- Using a variable in is_page(array())
- Remove duplicates – array_unique()
- Recent posts with featured image or fallback image with permalink
- Storing Array from returned database query and using the array in a new query
- get_the_tags() not iterating through for/while loop, but will with foreach
- get a simple array of all of the term names that exist in all taxonomies
- How to use $query->set with post__in?
- Reprinting tags with all attributes
- Exclude posts based on meta value
- Checking array against author id in loop
- Alter required message using comment form api
- Advanced Custom Fields – display label and value only if value entered
- wp_force_remove_style’ not found
- How can I access string value in an array?
- How to use if statement in an array? [closed]
- How to array only one key from another array
- Filtering a function’ output for a new continued function
- Update post title from external file?
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Get categories names as an array to use it in theme settings
- How to get the last category name of a child category?
- How to say if meta_value is greater than 0 in an array?
- Foreach loop inside an array_merge
- If Array Values Match Another Array’s Values, Then
- WordPress loop by meta key that is an array? and how loop multiple arrays
- How can I get all values from my array in a loop in php? [closed]
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- I’m unable to call img path using single quotes in an array?
- Comapare get_user_meta value
- How can get all users by current user meta?
- Get the id of all images in a post
- Output category list inside array
- how to make an array of post id’s in is_single
- Separate array output into a
- array_rand not working correctly?
- Get css class of menu item in custom menu structure
- Dynamically adding filters
- Update value of a associative array with update_post_meta
- Wp_editor doesn’t send the required data
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Add custom fields from different posts
- MySQL Query Returns Array () In Shortcode
- Sending simple variable on single page to WP JSON
- Create an array with all the links of the years’ archive (of a custom post type)
- Order users by random not working?
- Redux option doensn’t seem when include from functions.php
- in_array not working on dev server but works on localhost
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- wp_update_post gives 500 internal error
- Display one random image from Media Library
- How to display MySQL table data which is stored as an array?
- Show the subcategory name based on current product
- How to filter specific element of an array in wordpress/php?
- get_category_parents to array
- Notice : Array to string conversion on array_intersect user meta
- Remove item from post_meta array via AJAX
- Make sticky post with FacetWP
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- Display posts using post ID’s in an array
- How can i iterate through this shortcode array?
- Display a single row from nested array of custom field data
- How to use foreach and if statement within array of arrays?
- Reformat data within a nested array
- How to find the function which is outputting Array
- Create Customization Controls from Array
- Non-array argument in array_merge()-function [closed]
- Exclude Post ID from Array Specified in Custom Field
- !in_array doesnt recognize category
- Showing all post from all post type in admin backstage
- How to set if meta_value is lower < than other meta_value in a get_posts array?
- Populate checkboxes from array
- PHP Use Declared array Variable inside already Declared Array
- Force array to be a string [closed]
- Why is my array_diff usage breaking things?
- How to group by column a and sum column b and c in a php array
- Replace block content with an array
- Adding date and time to the same request
- PHP how to submit array elements to database
- Get check box values inside array for use in posting form data
- Warning: Array to string conversion in /css/base.php on line 500 [closed]
- Inserting more than one array into same row