You can check this code I am able to work with this
function cutom_function() {
$new_page_id = wp_insert_post( array(
'post_title' => 'PKB',
'post_type' => 'page',
'post_name' => 'pkb',
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_content' => '',
'post_status' => 'publish',
'post_author' => get_user_by( 'id', 1 )->user_id,
'menu_order' => 0,
// Assign page template
'page_template' => 'pratik.php'
) );
Related Posts:
- Creating a post with the REST API, curl and oauth returning 401 error
- Does the REST API (official) support custom post types?
- How to show single category archive
- Woocommerce api: create product with images – bad request
- Building a REST API for your web app exposes primary keys of DB records?
- Is it possible to create new user from external form using REST API?
- How to clone all WordPress Rest API end points
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Require()/Include() post template adding extra content
- How do i post data to url with fields?
- Adding Microsoft Teams Incoming Webhook to WordPress, Problem with Rest Route?
- REST API Plugin Update call back not updating the plugin
- Can external API content be added to Rest API in WordPress
- Change title only in dynamic page
- how to save selected option in variable for rest api category filter
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- Fetching instagram api not working on wordpress
- How can I edit the content in index.php? [duplicate]
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- how to show only specific category for a template
- Show a different code on front page to other pages
- Does wordpress templates always in files or in database?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Using same variable names in files added with get_template_part()
- PHP include is only working in certain places in my custom WP theme
- Use WordPress function in php file
- Adding wrapper elements in the_date() like in the_title()?
- How to get all author posts outside of author templates
- How can I call specific function if requested URL is not found?
- Add filter multiple times using only one master function
- Create a Blog Template Page
- Showing latest post without 301 redirect
- JSON REST API WordPress only showing first 10 categories
- WordPress template page name displayed on screen
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Buddypress update user avatar image via REST
- single.php with different look by category
- Delete taxonomy and delete all post related it
- How to call multiple functions from multiple files into a WordPress page template [closed]
- How do I define a lookup table that will work across all PHP elements of the template?
- persist a variable set in header.php all the way down to footer.php
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Removing WordPress Footer -without access to PHP code?
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Permission callback to check if user has application password
- Multiple requests external data api dynamic block gutenberg
- Why does the Woocommerce grouped template prints the unpublished products?
- Adding conditional text to a PHP Shortcode Template
- Create page template via functions.php?
- How can I spin up a new website for a registered user automatically?
- Simple WordPress endpoint route doesn’t work
- Cant register rest routs from class instance
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- WordPress REST API register_rest_route give a 500 error
- WC_Customer delete function returns error
- how to display this functions?
- is_page_template showing partial results
- Adding regular php file to site
- Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)
- add_filter function concatenate string and locate_template function
- Custom route and query
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- How to render a block from php template
- Template Loop – add switch case php
- Override Admin menu icon
- Post repeated when opening in overlay, how do I solve this? [closed]
- Filter by field with array value in ACF on WP REST API
- REST API works in browser and via AJAX but fails via cURL
- How to suppress template-parts in undescores?
- Need help with pagination
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Creating custom page template from existing PHP site
- How do I query a single data value from the wp_metadata table?
- Conditional string comparison failing for basename/slug
- Splitting the_content() by size?
- Gravity Forms merge tags in templates?
- Unable to render custom field after attempt to generate a list of recent post in page template
- How to add new CSS file to new PHP file
- php loading different structure than source code
- pass html code to worpdress
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Getting a WordPress tag to print inside of a traditional php echo
- Export post data with xml to other site using php soap
- no_rest_route error on custom routes
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Loading Elementor templates in a Bootstrap modal on button clicking
- Generate images with html2canvas and the woocommerce api
- Creating a brand attribute as a variable
- WordPress api post image raw data without being blank in media library
- REST api returns 404 on some WordPress sites
- Prevent header and footer from loading on specific pages with template or plugin
- Display articles with a different template in the home page | Solved |
- Display metabox galleries on specific page template in admin editor
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- Run do_shortcode on php template using JS function
- How to hardcode header and footer in WP?