Thursday, June 2, 2022
HomeWordPress Developmentdeprecation - WordPress 6.0 improve induced my customized operate to cease working

deprecation – WordPress 6.0 improve induced my customized operate to cease working


Not engaged on WordPress 6.0:
https://thealliance.well being/for-providers/assets/provider-news-archives/

Working dev web site on WordPress 5.9.3: https://ccahdev.wpengine.com/for-providers/assets/provider-news-archives/

Right here is the operate if someone can spot what might have been deprecated:

operate wpb_postsbycategory2022() {

$posts = get_posts( array(
    'category_name' => 'Supplier Information',
    'nopaging'  => true,
    'orderby'   => 'date',
    'order'     => 'DESC', // it is DESC; not DSC
    // There isn't any use setting posts_per_page when nopaging is enabled.
    // As a result of posts_per_page will likely be ignored when nopaging is enabled.
) );

$_year_year="";   // earlier years worth
$_year_mon = '';   // earlier year-month worth
$_has_grp = false; // TRUE if a bunch was opened
$_has_grpy = false; // TRUE if a bunch was opened
    
    
foreach ( $posts as $publish ) {
    setup_postdata( $publish );

    $time = strtotime( $post->post_date );
    $yr = date( 'Y', $time );
    $mon = date( 'F', $time );
    $year_mon = "$year-$mon";
    $year_year = "$yr";
    
    // Open a brand new group for yr.
    if ( $year_year !== $_year_year ) {
        // Shut earlier group, if any.
        if ( $_has_grpy ) {
            echo '</div><!-- .yr -->';
        }
        $_has_grpy = true;

        echo "<div class="yr" id='yr$yr'>";
        echo "<h2>$yr</h2>";
    }
    
    
    if ( $year_mon !== $_year_mon) {
        // Shut earlier group, if any.
        $_has_grp = true;

        echo '<div class="month">';
        echo "<span>$mon</span>";
    }

// Show publish title.
if ( $title = get_the_title() ) {
    echo "<div><a href="https://wordpress.stackexchange.com/?p={$post->ID}">{$post->post_title}</a></div>";
    }   
    
    if ( $year_mon !== $_year_mon) {
        // Shut earlier group, if any.
            echo '</div><!-- .month -->';
    }
    
    $_year_mon = $year_mon;
    $_year_year = $year_year;
}

// Shut the final group, if any.
// 
    
if ( $_has_grpy ) {
    echo '</div>';
}
    
    
/* Restore authentic Put up Information */
    
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
    
wp_reset_postdata();
}
// Add a shortcode
add_shortcode('categoryposts2022', 'wpb_postsbycategory2022');

Thanks for any help!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments