Hmm, that is more involved than I expected 🙂
function gwolle_gb_show_latest_entry() { $entries = gwolle_gb_get_entries( array( 'offset' => 0, 'num_entries' => 1, 'checked' => 'checked', 'trash' => 'notrash', 'spam' => 'nospam', ) ); $output = '<div class="gwolle-gb">'; $entries_list_class = 'gwolle-gb-read gwolle-gb-single-entry'; if ( is_array( $entries ) && ! empty( $entries ) ) { foreach ( $entries as $entry ) { $entries_list_class = apply_filters( 'gwolle_gb_entries_list_class', $entries_list_class ); $output .= '<div class="' . esc_attr( $entries_list_class ) . '">'; $first = true; $counter = 0; $output .= gwolle_gb_single_view( $entry, $first, $counter ); $output .= '</div>'; // Add filter for the complete output. $output = apply_filters( 'gwolle_gb_entries_read', $output); } // Load Frontend CSS in Footer, only when it's active wp_enqueue_style('gwolle_gb_frontend_css'); //wp_enqueue_script('jquery'); wp_enqueue_script('gwolle_gb_frontend_js'); } $output .= '</div>'; return $output;}add_shortcode( 'shortcode_gwolle_gb_show_latest_entry', 'gwolle_gb_show_latest_entry' );
I hope this Gutenberg Editor manages this 😉
What a mess this editor makes 🙂 Do you manage to format it into readable code? I made a shortcode of it. An action is possible as well.
For an admin, there is no parameter for moderator, only a no_moderator parameter.
There is an author_id, I hope that suffices. You can add a parameter 'author_id' => 1 to the gwolle_gb_get_entries function call, where 1 is the user_id of the moderator.
I am thinking the shortcode needs a num_entries parameter. The settings provide in this, but that is global. With a parameter to the shortcode this usecase would be much simpler.
Hi, yes, it is a mess 🙂
Instead of using this code, it is much easier for both of us if we just use the num_entries parameter to the shortcode. You can find it in the latest git from here:
https://codeberg.org/cyclotouriste/gwolle-gb
You can simply use it as [gwolle_gb num_entries="1"] and it should only show one entry.