Adding a single text input field to a custom Dashboard widget

You need a set of functions to : process datas sanitize options allow datas to be updated output the form I like to proceed this way. I set also a function to grab datas so I can call them the simpliest way : add_action(‘wp_dashboard_setup’, ‘wpse_106458_add_widget’); function wpse_106458_add_widget() { $title = my_function_get_options(); $title = $title[‘title’]; wp_add_dashboard_widget(‘widget_id’, … Read more

How to set custom cookies in WordPress after a form is filled on a page

Your page-xyz.php has to look like this: $cookie_set = isset( $_COOKIE[‘mycookie’] ); if ( $_SERVER[‘REQUEST_METHOD’] == ‘POST’ ) : // exec your mysql queries and do else stuff… // after it set your cookie setcookie(‘mycookie’, ‘some value’); $cookie_set = true; endif; if ( $cookie_set ) : // render your content here else : // render … Read more

Select post from dropdown and add query args not working

Rename your <select> to something other than page_id. The problem is that page_id is already taken (and handled) by WordPress (as query var). This should do, for example: <?php if (isset($_GET[‘editevent’]) && true == $_GET[‘editevent’]) echo ‘Post ID: ‘.$_GET[‘my_page_id’]; ?> <form method=”GET” action=”#”> <select name=”my_page_id” id=”my_page_id” onchange=”this.form.submit()”> <?php $args = array( ‘posts_per_page’ => -1, ‘post_type’ … Read more

Search form options group categories

You can use in search query wp public query vars. When searching in multiple categories, wordpress accepts comma separated category ids in url &cat=1,2,5 Now I can come up with only such simple solution. Get rid of wp_dropdown_categories use e.g. get_categories, so you can customize SELECT attribute name into cat[] (which is also possible with … Read more