Site icon Hip-Hop Website Design and Development

Any concepts the right way to exclude a "Featured" submit?

I wish to use the question to seize all the things apart from "Featured" within the second args question, and for the "Featured" submit to be the primary merchandise listed. Proper now "Featured" is duplicating. The primary Featured submit hyperlink is right, however have to eliminate the second Featured submit hyperlink.

Here’s a screenshot:

Right here is the code:

<?php
perform exclude_term_by( $taxonomy = 'class', $args = [], $exclude = [] )
{
    /**
     * If there aren't any time period slugs to exclude or if $exclude just isn't a legitimate array, return get_terms
     */
    if ( empty( $exclude ) || !is_array( $exclude ) )
        return get_terms( $taxonomy, $args );

    /**
     * If we attain this level, then we've got phrases to exclude by slug
     * Merely proceed the method. 
     */ 
    foreach ( $exclude as $worth ) {

            /**
             * Use get_term_by to get the time period ID and add ID's to an array
             */
            $term_objects = get_term_by( 'slug', $worth, $taxonomy );
            $term_ids[] = (int) get_queried_object()->term_id;

    }

    /**
     * Arrange the exclude parameter with an array of ids from $term_ids
     */
    $excluded_ids = [
        'exclude' => $term_ids
    ];

    /**
     * Merge the person handed arguments $args with the excluded phrases $excluded_ids
     * If any worth is handed to $args['exclude'], it will likely be ignored
     */
    $merged_arguments = array_merge( $args, $excluded_ids );

    /**
     * Lets move all the things to get_terms
     */
    $phrases = get_terms( $taxonomy, $merged_arguments ); 

    /**
     * Return the outcomes from get_terms
     */
    return $phrases;
}
$phrases = exclude_term_by( 'class', [], ['featured', 'corporate'] );
if ( !empty( $phrases ) && !is_wp_error( $phrases ) ) {
    ?>
    <div class="category-filter full">
        <span class="filter-text"><i class="far fa-filter"></i> <?php esc_html_e( 'Filter by:', 'siemens-wp' ); ?></span>
        <ul class="category-list">
            <?php 
            // solely show "Featured" if a Featured submit is current within the weblog
                $question = new WP_Query(array(
                    'post_type' => 'submit',
                    'subject' => 'slug',
                    'category_name' => 'featured',
                    'ignore_sticky_posts'    => 1,
                ));
                // That is intentional for the "Featured" submit to be the primary merchandise
                if( $query->have_posts() ){
                    echo '<li><a href="'. get_site_url() .'/category/featured/">Featured</a></li>';
                }
            wp_reset_postdata(); // Restore authentic Put up Knowledge
            ?>
            <?php
                $args = array(
                    'post_type'    => 'posts',
                    'showposts'    => -1,
                    'post_status'  => 'publish',
                    'father or mother' => 0,
                    'hide_empty' => true,
                    'tax_query' => array(
                        'taxonomy' => 'classes',
                        'subject'    => 'slug',
                        'phrases'    => array( 'featured' ), 
                        'operator' => 'NOT IN',
                    ),
                );
                $phrases = get_terms('classes', $args );
                foreach ( $phrases as $time period ) :
                    // This output doesn't work
                    printf( '<li><a href="%1$s">%2$s</a></li>',
                        esc_url( get_category_link( $term->term_id ) ),
                        esc_html( $term->identify )
                    );
                endforeach; 
            ?>
        </ul>
    </div>
    <div class="category-filter mobile">
        <choose id="custom-select" onchange="location = this.value;" model="outline:none;border:1px solid #777;font-size:20px;height:30px;color:#777;">
                <possibility worth="" disabled chosen hidden>Filter by Class</possibility>
            <?php 
                foreach ( $phrases as $time period ) {
                    printf( '<possibility worth="%1$s">%2$s</possibility>',
                        esc_url( get_category_link( $term->term_id ) ),
                        esc_html( $term->identify )
                    );
                }
            ?>
        </choose>
    </div>
     <?php
     wp_reset_postdata();
}   
?>

Any concepts on what the output can be within the foreach loop?