add_action( 'wp', $this, 'suppress_page_title' ); } /** * Fired on every frontend request for the projects archive page. * Sets pyre_page_title (Avada) and adds the_title filter (Gutenberg / any theme). */ public function suppress_page_title(): void { if ( ! is_singular( 'page' ) ) { return; } $archive_id = (int) get_option( 'academiccrew_collaborations_archive_page_id', 0 ); if ( ! $archive_id || get_queried_object_id() !== $archive_id ) { return; } update_post_meta( $archive_id, 'pyre_page_title', 'no' ); add_filter( 'the_title', [ $this, 'blank_archive_title' ], 10, 2 ); } /** Returns empty string for the archive page title rendered inside the loop. */ public function blank_archive_title( string $title, int $id = 0 ): string { $archive_id = (int) get_option( 'academiccrew_collaborations_archive_page_id', 0 ); return ( $archive_id && (int) $id === $archive_id && in_the_loop() ) ? '' : esc_html( $title ); } public function render( array $atts ): string { $atts = shortcode_atts( [ 'per_page' => -1, ], $atts, 'academiccrew_projects' ); $query = new \WP_Query( [ 'post_type' => 'acc_collaboration', 'post_status' => 'publish', 'posts_per_page' => (int) $atts['per_page'], 'orderby' => 'title', 'order' => 'ASC', ] ); // Most recent projects first (by start date), then A→Z by title. $start_of = static fn( \WP_Post $p ): string => (string) get_post_meta( $p->ID, '_acc_start_date', true ) ?: '0000-00-00'; usort( $query->posts, static function ( $a, $b ) use ( $start_of ) { return strcmp( $start_of( $b ), $start_of( $a ) ) ?: strcasecmp( $a->post_title, $b->post_title ); } ); wp_enqueue_script( 'academiccrew-projects-archive', ACADEMICCREW_URL . 'assets/js/projects-archive.js', [], ACADEMICCREW_VERSION, true ); $found = $query->found_posts; // Collect unique keyword labels (original case) for the datalist autocomplete. $all_keywords = []; foreach ( $query->posts as $post ) { $kw_raw = get_post_meta( $post->ID, '_acc_keywords', true ); foreach ( ( is_array( $kw_raw ) ? $kw_raw : [] ) as $kw ) { $kw = trim( (string) $kw ); if ( $kw !== '' && ! in_array( $kw, $all_keywords, true ) ) { $all_keywords[] = $kw; } } } sort( $all_keywords ); ob_start(); ?>

0 ) : ?>
have_posts() ) : ?>

posts as $post ) : $get = fn( string $k ) => get_post_meta( $post->ID, $k, true ); $ptype = (string) ( $get( '_acc_project_type' ) ?: '' ); $thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ) ?: ''; $kw_raw = $get( '_acc_keywords' ); $keywords = is_array( $kw_raw ) ? $kw_raw : []; $short_desc = (string) ( $get( '_acc_short_desc' ) ?: '' ); $start = (string) ( $get( '_acc_start_date' ) ?: '' ); $end = (string) ( $get( '_acc_end_date' ) ?: '' ); $dates = ''; if ( $start && $end ) { $dates = date_i18n( 'Y', strtotime( $start ) ) . '–' . date_i18n( 'Y', strtotime( $end ) ); } elseif ( $start ) { $dates = date_i18n( 'Y', strtotime( $start ) ) . '–' . esc_html__( 'ongoing', 'academiccrew' ); } $status = ( $end && strtotime( $end ) < time() ) ? 'completed' : 'ongoing'; $linked_members = (array) ( get_post_meta( $post->ID, '_acc_linked_members', true ) ?: [] ); $pi_name = \AcademicCrew\Meta\CollaborationMeta::extract_pi_name( $linked_members ); $linked_page_id = (int) get_post_meta( $post->ID, '_academiccrew_linked_page_id', true ); $url = $linked_page_id ? get_permalink( $linked_page_id ) : get_permalink( $post->ID ); $start_year = $start ? (int) date_i18n( 'Y', strtotime( $start ) ) : 0; $kw_data = implode( '|', array_map( fn( $k ) => strtolower( trim( $k ) ), $keywords ) ); ?>
<?php echo esc_attr( $post->post_title ); ?>

post_title ); ?>

PI ·