Vor gut einem Jahr habe ich euch bereits gezeigt wie ihr Schlagwörter / Tags in die Blogbeiträge einbinden könnt (DIVI: Wie binde ich Schlagwörter / Tags in Blogbeiträge ein?). Und heute zeige ich euch wie man diese Schlagwörter / Tags direkt in das Divi Blogmodul einbinden könnt. Und ja es ist egal ob ihr das Modul als Grid eingebaut habt oder im Full-Width Design – die Tags und Schlagwörter werden immer angezeigt.
Video
Functions
/* add tag to blog module */
function cb_add_blog_module_article_filter($content) {
if (is_array($content)) { return $content; }
return preg_replace_callback('/<article.*?<\/article>/s', 'cb_apply_blog_module_article_filter', $content);
}
add_filter('et_pb_blog_shortcode_output', 'cb_add_blog_module_article_filter');
function cb_apply_blog_module_article_filter($match) {
if (!is_array($match) || !isset($match[0])) { return $match; }
return apply_filters('blog_module_article', $match[0]);
}
add_filter('blog_module_article', 'cb_blog_module_add_tags');
function cb_blog_module_add_tags($html) {
$match = false;
preg_match('/<article id="post-(\d*)"/', $html, $match);
$id = isset($match[1])?intval($match[1]):false;
if (!$id) { return $html; }
$tags = get_the_tag_list('', ', ', '', $id);
if (empty($tags)) { return $html; }
if (strpos($html, '<p class="post-meta">') !== false) {
$html = preg_replace('/(<p class="post-meta">.*?)(<\/p>)/s', '\\1 | '.$tags.'\\2', $html);
} else {
$html = preg_replace('/(<div class="post-content">)/s', '<p class="post-meta">'.$tags.'</p>\\1', $html);
}
return $html;
}






Neueste Kommentare