Beiträge von glueckpress
-
-
Auf die Schnelle: das Folgende in der functions.php des aktiven Themes ablegen.
Disclaimer: Nur rudimentär getestet, keinerlei Gewähr. Bitte zuerst in Testumgebung ausprobieren!PHP
Alles anzeigen/* Custom Query function */ function gp_newsbox() { // The query $gp_newsbox = new WP_Query( array( 'post_type' => 'post', 'post_status' => 'published', 'post_count' => 5 ) ); // No posts in the query if( ! $gp_newsbox->have_posts() ) echo ''; $output = '<div class="news-box">'."\n"; $output .= '<ul>'."\n"; // The Loop while ( $gp_newsbox->have_posts() ) : $gp_newsbox->the_post(); $output .= '<li><h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3></li>'."\n"; // Add your own markup as you see fit. endwhile; // End of the Loop $output .= '</ul>'."\n"; $output .= '</div><!-- .news-box -->'."\n"; return $output; } // Put the whole thing in a shortcode function gp_newsbox_shortcode( $atts, $content = null ) { $content = gp_newsbox(); return $content; } // Add shortcode add_shortcode( 'newsbox', 'gp_newsbox_shortcode' );