', esc_url(get_bloginfo('pingback_url'))); } } add_action('wp_head', 'blog_build_pingback_header'); /** * Custom pagination function for Blog Build theme * * Displays pagination with ellipses and custom styling */ function blog_build_pagination() { the_posts_pagination(array( 'mid_size' => 1, 'prev_text' => __('Previous', 'blog-build'), 'next_text' => __('Next', 'blog-build'), 'screen_reader_text' => __('Posts Navigation', 'blog-build'), 'aria_label' => __('Posts', 'blog-build'), 'class' => 'blog-build-pagination', )); } function blog_build_sanitize_footer_copyright($input) { $allowed_html = array( 'a' => array( 'href' => array(), 'title' => array(), 'class' => array(), 'target' => array(), 'rel' => array(), ), 'p' => array( 'class' => array(), ), 'span' => array( 'class' => array(), ), ); return wp_kses($input, $allowed_html); } /** * Display category badge(s) for posts * * @param bool $single Whether to display a single random category (true) or all categories (false) */ function blog_build_display_random_category_badge($single = true) { $blog_build_show_categories = get_theme_mod('blog_build_show_categories'); $blog_build_single_show_categories = get_theme_mod('blog_build_single_show_categories', 1); if ('post' != get_post_type()) { return; // Only for posts } if ( empty($blog_build_show_categories) && !is_single() ) { return; } if ( empty($blog_build_single_show_categories) && is_single() ) { return; } // Static variables preserve value between function calls static $post_index = 0; // Define background color classes (you can customize these) $bg_classes = array('cat-bg-1', 'cat-bg-2', 'cat-bg-3', 'cat-bg-4', 'cat-bg-5', 'cat-bg-6'); // Increment post index $post_index++; // Get categories $categories = get_the_category(); if (!empty($categories)) { if ($single) { // Display a single random category (original behavior) $random_cat_index = array_rand($categories); $random_cat = $categories[$random_cat_index]; $current_color_class = $bg_classes[($post_index - 1) % 6]; echo '' . esc_html($random_cat->name) . ''; } else { // Display all categories with rotating background colors // Open wrapper div for multiple categories echo '
'; $cat_index = 0; foreach ($categories as $category) { $current_color_class = $bg_classes[($post_index + $cat_index) % 6]; echo '' . esc_html($category->name) . ' '; $cat_index++; } // Close wrapper div echo '
'; } } } /** * Display tag list with # prefix and each tag wrapped in a div * * @param bool $show_label Whether to display the "Tagged" label before the tags */ function blog_build_display_tag_list($show_label = true) { if ('post' != get_post_type()) { return; // Only for posts } // Check if we should display tags based on customizer setting if (is_single()) { $show_tags = get_theme_mod('blog_build_single_show_tags', 1); if (!$show_tags) { return; // Don't display tags if disabled in customizer } } // Get all tags for the current post $tags = get_the_tags(); // If there are no tags, return early if (empty($tags)) { return; } // Start the tags container echo '
'; // Show the label if requested if ($show_label) { echo '' . esc_html__('Tagged', 'blog-build') . ' '; } // Start the tags wrapper echo '
'; // Loop through each tag and display it foreach ($tags as $tag) { echo ''; } // Close the tags wrapper echo '
'; // Close the tags container echo '
'; }