ID ); if ( $tags ) { $show = true; $tag_ids = array(); foreach ( $tags as $individual_tag ) { $tag_ids[] = $individual_tag->term_id; } $args = array( 'tag__in' => $tag_ids, 'post__not_in' => array( $post->ID ), 'posts_per_page' => $post_qty, 'ignore_sticky_posts' => 1, ); } break; default: $categories = get_the_category( $post->ID ); if ( $categories ) { $show = true; $category_ids = array(); foreach ( $categories as $individual_category ) { $category_ids[] = $individual_category->term_id; } $args = array( 'category__in' => $category_ids, 'post__not_in' => array( $post->ID ), 'showposts' => $post_qty, 'ignore_sticky_posts' => 1, ); } endswitch; if ( true === $show ) { $related = new wp_query( $args ); if ( $related->have_posts() ) { $layout = ''; echo wp_kses_post( $layout ); } wp_reset_postdata(); } } endif; /* * * * WordPress number pagination * * */ if ( ! function_exists( 'aari_number_paging_nav' ) ) : function aari_number_paging_nav() { // Don't print empty markup if there's only one page. if ( $GLOBALS['wp_query']->max_num_pages < 2 ) { return; } $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $pagenum_link = html_entity_decode( get_pagenum_link() ); $query_args = array(); $url_parts = explode( '?', $pagenum_link ); if ( isset( $url_parts[1] ) ) { wp_parse_str( $url_parts[1], $query_args ); } $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%'; // Set up paginated links. $links = paginate_links( array( 'base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map( 'urlencode', $query_args ), 'prev_next' => true, 'prev_text' => '', 'next_text' => '', ) ); if ( $links ) : $layout = '
'; $layout .= ''; $layout .= '
'; echo wp_kses_post( $layout ); endif; } endif; /** * breadcrumbs */ if ( ! function_exists( 'aari_breadcrumbs' ) ) : function aari_breadcrumbs() { /* === OPTIONS === */ $text['home'] = 'Home'; // text for the 'Home' link $text['category'] = 'Archive by Category "%s"'; // text for a category page $text['search'] = 'Search Results for "%s"'; // text for a search results page $text['tag'] = 'Posts Tagged "%s"'; // text for a tag page $text['author'] = 'Articles Posted by %s'; // text for an author page $text['404'] = 'Error 404'; // text for the 404 page $show_current = 1; // 1 - show current post/page/category title in breadcrumbs, 0 - don't show $show_on_home = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $show_home_link = 1; // 1 - show the 'Home' link, 0 - don't show $show_title = 1; // 1 - show the title for the links, 0 - don't show $delimiter = ' » '; // delimiter between crumbs $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb /* === END OF OPTIONS === */ global $post; $home_link = home_url( '/' ); $link_before = ''; $link_after = ''; $link_attr = ' rel="v:url" property="v:title"'; $link = $link_before . '%2$s' . $link_after; is_singular() === $post ? get_queried_object() : false; if ( $post ) { $parent_id = $post->post_parent; $parent_id = $post->post_parent; } else { $parent_id = 0; $parent_id = 0; } $frontpage_id = get_option( 'page_on_front' ); if ( is_home() || is_front_page() ) { if ( 1 === $show_on_home ) { echo ''; } } else { echo wp_kses_post( ''; } } // end dimox_breadcrumbs() endif; /* * Change archive page title */ add_filter( 'get_the_archive_title', function ( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } elseif ( is_author() ) { $title = '' . get_the_author() . ''; } return $title; } ); /* * Remove migrate js */ function aari_dequeue_jquery_migrate( $scripts ) { if ( ! is_admin() && ! empty( $scripts->registered['jquery'] ) ) { $scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) ); } } add_action( 'wp_default_scripts', 'aari_dequeue_jquery_migrate' ); /* * create copyright info */ function aari_copyright() { $all_posts = get_posts( 'post_status=publish&order=ASC' ); $first_post = $all_posts[0]; $first_date = $first_post->post_date_gmt; esc_html_e( 'Copyright © ', 'aari' ); if ( substr( $first_date, 0, 4 ) === date( 'Y' ) ) { echo wp_kses_post( date( 'Y' ) ); } else { echo wp_kses_post( substr( $first_date, 0, 4 ) ) . '-' . wp_kses_post( date( 'Y' ) ); } echo '' . esc_html( get_bloginfo( 'name' ) ) . '.'; esc_html_e( ' All rights reserved.', 'aari' ); } /* * Get comment depth */ function aari_get_comment_depth( $my_comment_id ) { $depth_level = 0; while ( $my_comment_id > 0 ) { // if you have ideas how we can do it without a loop, please, share it with us in comments $my_comment = get_comment( $my_comment_id ); $my_comment_id = $my_comment->comment_parent; $depth_level++; } return $depth_level; } /* * Return safe css */ add_filter( 'safe_style_css', function( $styles ) { $styles[] = 'display'; $styles[] = 'background-size'; $styles[] = 'background-repeat'; $styles[] = 'background-position'; return $styles; } );