Dashboard
Syntax highlight your source code by specifying the programming language and theme.
Powered by Torchlight.
Output
<?php function get_link_attributes( WP_Post $post ) { $post_meta = get_post_meta( $post->ID, '_llcu_box_attrs', true ); $attributes = 'Sub1: ' . ( $post_meta['sub1'] ?? '' ) . ' || Sub2: ' . ( $post_meta['sub2'] ?? '' ); $permalink = get_permalink( $post->ID ); $slug = str_replace( home_url(), '', $permalink ); return [ 'post_id' => $post->ID, 'slug' => '=HYPERLINK("' . $permalink . '";"' . $slug . '")', 'sub1' => $post_meta['sub1'] ?? '', 'sub2' => $post_meta['sub2'] ?? '', ];} $posts = get_posts( [ 'numberposts' => -1, 'post_type' => ['post', 'page'],] ); foreach ( $posts as $post ) { $attributes = get_link_attributes( $post ); if ( empty( $attributes ) ) { continue; } echo implode( ',', $attributes ) . PHP_EOL;}
HTML