Save and user submitted data from a form and display them in the wp backend

Can you just tell me how I can grab the input value for “name” and add the entry to custom_post_type? Sure thing: if ( isset( $_POST[‘name’] ) ) { $name = sanitize_text_field( wp_unslash( $_POST[‘name’] ) ); if ( $name ) { wp_insert_post( array( ‘post_title’ => $name, ‘post_type’ => ‘my_post_type’, ‘post_status’ => ‘publish’, /* Or “draft”, … Read more

Allow HTML in Settings API input field

When you register a setting, you pass the santize callback for that setting: register_setting( ‘my_setting_group’, ‘my_setting_name’, // The next parameter is the validation callback ‘my_setting_validation’ ); Then, in the validation callback you can allow whatever you want. For example, in the next code snippet, users with unfiltered_html capability will be allowed to insert raw HTML … Read more

Update the value of a constant

You can’t alter a constant once it is defined. That is how PHP works. Don’t fight it. The good news is that you should not be using a constant at all. Use options. // get your value // the second parameter is the default $enable_paypal = get_option(‘enable_paypal’,true); // set your value based on, I assume, … Read more

Sizing textarea field in custom metabox

You could try styling it with CSS by adding an ID or a class to the textarea and inserting styles into the wp_admin head. Or, a quick way would be to do something like this : echo ‘<textarea name=”_dresscode” class=”widefat” style=”width:400px !important; height:80px !important;” >’ . $dresscode . ‘</textarea>’; If not, have you tried simply … Read more

WordPress (admin) posts search GET request filter

function getPostsByCategorySlug(slug) { return site.categories().slug( slug ) .then(function( matchingCats ) { // matchingCats will be an array of the one post that matches // the provided slug if ( ! matchingCats.length ) { throw new Error( `No category found for slug “${slug}”` ); } var catID = matchingCats[ 0 ].id; return site.posts().categories(catID); }); } getPostsByCategorySlug( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)