How to redirect if is post edit or publish page?

For what you want to achieve, using the id instead of post-type should do the job. Try this: add_action(‘admin_menu’, ‘custom_redirect_function’); function custom_redirect_function() { $screen = get_current_screen(); if ( $screen->id == “edit-post” ) { wp_redirect( site_url() ); exit(); } } References: get_current_screen wp_redirect

On WordPress Search, how to search post from Author meta also

You can start with prepare information what you need using MySQL SELECT * FROM `wp_usermeta` WHERE `meta_key` = “description” For example, you can create the file with the prepared output of your custom query and then use jQuery * Ajax for your search box.. I’ve show you sample of json file: <?php require_once(‘../../../wp-load.php’); $gm = … Read more

how let users select categories for posts in frontend?

here is how to do it: <form action=”#” method=”post”> <input type=”checkbox” name=”checklist[]” value=”1″><label>Blue</label> <input type=”checkbox” name=”checklist[]” value=”2″><label>Red</label> … <input type=”submit” name=”submit” value=”submit”/> </form> <?php if(isset($_POST[‘submit’])){ if(!empty($_POST[‘checklist’])){ $selectArr = array(); foreach($_POST[‘checklist’] as $selected){ $selectedInt = (int)$selected; $selectArr[] = $selectedInt; wp_set_object_terms( $thePostId, $selectArr, ‘color’); } } } ?> where the values in input tags are taxonomies IDs … Read more

Creating a link to the first post in a category

Given a category ID, in this example as the variable $cat_id, you would do this by querying 1 post in that category, ordered by date in ascending order (oldest first). Then use that result to get the permalink to that post. $posts = get_posts( ‘numberposts’ => 1, ‘order’ => ‘ASC’, ‘cat’ => $cat_id, ); if … Read more

Page with Category Returning 1

few things here: 1) Your WP_Query args doesn’t look good, the proper way of querying posts by taxonomy should be: $splash_page_args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => ‘3’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘splash-homepage’, ), ), ); 2) Is there any particular reason why you’re using foreach … Read more