Auto-change Post Status on First Page Load

If you want the default post status to be in-progress when contributors click on “New Post”, then you can try the following: /** * Set default post status as ‘in-progress’ for contributors * * @link https://wordpress.stackexchange.com/a/143128/26350 * * @param array $data * @return array $data */ function wpse_143100_wp_insert_post_data( $data ) { $current_user = wp_get_current_user(); if( … Read more

Get posts in between specific ID’s

You can simply just use the post__in parameter inside your query arguments or inside your pre_get_posts action EXAMPLE (Adjust as necessary. Code requires at least PHP 5.4+ due to short array syntax ([])) $args = [ ‘post__in’ => range( 10, 15 ), ]; $q = get_posts( $args ); var_dump( $q );

Query get_posts by level depth

You’ll need to run two queries here First query we will be returning all top level pages (I assume Asia, Africa and America is top level pages) Second query we will get all direct children of the top level pages returned You can try something like the following: $parent_id_args = [ ‘post_parent’ => 0, // … Read more

Unique Problem with the php date and get_posts

date returns a string but you are using integers in the switch statement. Use: case ’01’: $dateY = date(‘Y’)+1; break; etc. However, the switch code can be much simpler, and there is no need to call the date function again since dateY has already been initialised in advance: switch($dateM) { case ’01’: case ’02’: case … Read more

Inserting post content into pages when using custom taxonomies

That code never outputs anything to the page: <?php if(has_term(‘ART’, ‘product_relevance’)): $my_post = get_post(927); if(isset($my_post->post_content)): ?> <div class=”row”> <div class=”notification col-lg-9 order-1″> <?php echo $my_post->post_content; ?> </div> </div> <?php endif; ?> <?php endif; ?> Untested, but in essence you need to do something with the post content.

Iterate over get_post_meta() result

You’re clobbering the value in the $users array with every iteration of the foreach loop. To add a new item to an array, you should use $users[] = {…}, not $users = {…}. function get_preselect_values() { $volunteers = get_post_meta($_POST[‘element_id’], “volunteers”, false); $users = array(); foreach ($volunteers as $volunteer) { foreach ($volunteer as $volun) { $users[] … Read more

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