How Do You Add a Textbox in WordPress?
on 25 August, 2022
No Comments
Adding a textbox in WordPress is quite simple. All you need to do is add the following code to your theme’s functions.php file:
/**
* Add a textbox to a post or page
*/
function textbox_add() {
global $post, $page;
$post = get_post();
if (!is_post_type_archive($post->post_type)) {
$page = get_page();
} elseif (($page == null) || (!is_page_type_archive($page))) {
$page = get_post_meta($post->post_type, ‘page’, true);
}
if (!$page) {
$page = get_page_by_title($post->post_title);
$page = array(
‘post_type’ => ‘page’,
‘title’ => __(‘Page not found’),
);
$textbox = new WP_Textbox();
$textbox->set_title($page->get_title());
$textbox->set_page($page->get_page_id());
$textbox->set_post_type($post->post_type);
$textbox->set_html(__(‘