Support Forum » User Profile

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: How to remove the slug from the permalink of a CPT #44438
    ValVal
    Participant

    This plugin did the trick for me - https://wordpress.org/plugins/permalink-manager/

    But I'm as well thinking Meta Box should have this feature built in.

    in reply to: Can't check if current post is latest (CPT issue) #41839
    ValVal
    Participant

    Hi, thanks for answering! Unfortunately it didn't work, maybe there was something else wrong with the code snippet. I got another one that let me inline css with a shortcode. Here's the workaround in case anyone needs such a thing :

    function get_latest_project() {
        $current_post_id = get_the_ID();
    
        $args = array(
            'post_type'      => 'projects',
            'posts_per_page' => 1,
            'post_status'    => 'publish',
            'order'          => 'DESC',
            'orderby'        => 'date',
        );
    
        $query = new WP_Query( $args );
        
        $latest_post_id = null;
        if ( $query->have_posts() ) {
            $query->the_post();
            $latest_post_id = get_the_ID(); 
            wp_reset_postdata();
        } 
        
        $css = '<style>/* not latest */</style>';
        if ($latest_post_id AND $current_post_id == $latest_post_id) {
            $css = '<style>/* latest */</style>';
        }
    
        return $css;
    }
    add_shortcode( 'latest_project', 'get_latest_project' );
    
Viewing 2 posts - 1 through 2 (of 2 total)