Hallo Leute, ich modifiziere eben mein Template und stehe vor einer kleinen Hürde; ich würde gern die functions.php um einen weiteren Shortcode ergänzen.
Hier ist der Shortcode für [news] definiert:
PHP
function shortcode_posts_function(){
//Parameter für Posts
$args = array(
'category' => '1',
'numberposts' => 8
);
$posts = get_posts($args);
$content = '<div class="posts">';
foreach ($posts as $post) {
$content .= '<div class="post">';
$content .= '<a href="'.get_permalink($post->ID).'"><div class="title">'.$post->post_title.'</div></a>';
$content .= '<a href="'.get_permalink($post->ID).'"><img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="thumb"></a>';
$content .= '<a id="post-txt" href="'.get_permalink($post->ID).'">'.get_the_excerpt($post->ID) .'</a>';
$content .= '</div>';
}
$content .= '</div>';
return $content;
}
add_shortcode('news', 'shortcode_posts_function');
Alles anzeigen
Wie kann ich diese Funktion duplizieren und für für den Shortcode [aufgaben] anpassen?
Schonmal Danke für Eure Tipps!