add_shortcode(’toolsforge_blog_dynamic’, function () {
ob_start();
$paged = max(
1,
get_query_var(’paged’) ? get_query_var(’paged’) : get_query_var(’page’)
);
if (!function_exists(’tf_blog_read_time’)) {
function tf_blog_read_time($post_id) {
$content = get_post_field(’post_content’, $post_id);
$word_count = str_word_count(wp_strip_all_tags($content));
$minutes = max(1, ceil($word_count / 180));
return $minutes . ’ min czytania’;
}
}
if (!function_exists(’tf_blog_polish_date’)) {
function tf_blog_polish_date($post_id) {
$months = [
1 => 'stycznia’,
2 => 'lutego’,
3 => 'marca’,
4 => 'kwietnia’,
5 => 'maja’,
6 => 'czerwca’,
7 => 'lipca’,
8 => 'sierpnia’,
9 => 'września’,
10 => 'października’,
11 => 'listopada’,
12 => 'grudnia’,
];
$timestamp = get_post_timestamp($post_id);
$day = date_i18n(’j’, $timestamp);
$month_num = (int) date_i18n(’n’, $timestamp);
$year = date_i18n(’Y’, $timestamp);
return $day . ’ ’ . $months[$month_num] . ’ ’ . $year;
}
}
$featured_args = [
'post_type’ => 'post’,
'posts_per_page’ => 1,
'post_status’ => 'publish’,
'ignore_sticky_posts’ => false,
];
$featured_query = new WP_Query($featured_args);
$featured_id = 0;
if ($featured_query->have_posts()) {
$featured_id = (int) $featured_query->posts[0]->ID;
}
$posts_args = [
'post_type’ => 'post’,
'posts_per_page’ => 6,
'post_status’ => 'publish’,
'post__not_in’ => $featured_id ? [$featured_id] : [],
'paged’ => $paged,
'ignore_sticky_posts’ => true,
];
$posts_query = new WP_Query($posts_args);
$preferred_slugs = [’stoly-warsztatowe’, 'organizacja-warsztatu’, 'system-toolsforge’];
$topic_categories = [];
foreach ($preferred_slugs as $slug) {
$term = get_category_by_slug($slug);
if ($term && !is_wp_error($term)) {
$topic_categories[] = $term;
}
}
if (count($topic_categories) < 3) {
$fallback_terms = get_categories([
'hide_empty' => true,
'number’ => 3,
'orderby’ => 'count’,
'order’ => 'DESC’,
]);
foreach ($fallback_terms as $term) {
$already = false;
foreach ($topic_categories as $existing) {
if ((int) $existing->term_id === (int) $term->term_id) {
$already = true;
break;
}
}
if (!$already) {
$topic_categories[] = $term;
}
if (count($topic_categories) >= 3) {
break;
}
}
}
?>
Blog ToolsForge
Praktyczna wiedza o warsztacie i systemie ToolsForge
Tutaj znajdziesz artykuły o stołach warsztatowych, organizacji stanowiska pracy,
praktycznych problemach z warsztatu i rozwiązaniach, które powstają z realnego doświadczenia.
have_posts()) : ?>
have_posts()) : $featured_query->the_post(); ?>
Wyróżniony artykuł
Zacznij od najważniejszego tematu