افزودن Breadcrumbs به مطالب سایت

  • نویسنده موضوع sir1
  • تاریخ شروع

sir1

کاربر عضو
سلام
قابلیت Breadcrumbs را در افزونه یواست فعال کردم ولی بایستی کد زیر را در header.php یا single.php در جای مناسب قرار دهم تا Breadcrumbs ها در نتایج گوگل نشان داده شود.
لطفا در یکی از این فایل ها کد را جایگذاری کنید تا در هاست هم تغییر بدم.
کد Breadcrumbs
کد:
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('
<p id="breadcrumbs">','</p>
');
}
?>


کد فایل header.php
کد:
<?php
    if ( ! defined('ABSPATH') ){ die(); }
    
    global $avia_config;
    
    $lightbox_option = avia_get_option( 'lightbox_active' );
    $avia_config['use_standard_lightbox'] = empty( $lightbox_option ) || ( 'lightbox_active' == $lightbox_option ) ? 'lightbox_active' : 'disabled';
    /**
     * Allow to overwrite the option setting for using the standard lightbox
     * Make sure to return 'disabled' to deactivate the standard lightbox - all checks are done against this string
     *
     * @added_by G端nter
     * @since 4.2.6
     * @param string $use_standard_lightbox                'lightbox_active' | 'disabled'
     * @return string                                    'lightbox_active' | 'disabled'
     */
    $avia_config['use_standard_lightbox'] = apply_filters( 'avf_use_standard_lightbox', $avia_config['use_standard_lightbox'] );

    $style                     = $avia_config['box_class'];
    $responsive                = avia_get_option('responsive_active') != "disabled" ? "responsive" : "fixed_layout";
    $blank                     = isset($avia_config['template']) ? $avia_config['template'] : "";   
    $av_lightbox            = $avia_config['use_standard_lightbox'] != "disabled" ? 'av-default-lightbox' : 'av-custom-lightbox';
    $preloader                = avia_get_option('preloader') == "preloader" ? 'av-preloader-active av-preloader-enabled' : 'av-preloader-disabled';
    $sidebar_styling         = avia_get_option('sidebar_styling');
    $filterable_classes     = avia_header_class_filter( avia_header_class_string() );
    $av_classes_manually    = "av-no-preview"; /*required for live previews*/

    /**
     * Allows to alter default settings Enfold-> Main Menu -> General -> Menu Items for Desktop
     * @since 4.4.2
     */
    $is_burger_menu = apply_filters( 'avf_burger_menu_active', avia_is_burger_menu(), 'header' );
    $av_classes_manually   .= $is_burger_menu ? " html_burger_menu_active" : " html_text_menu_active";

    /**
     * Add additional custom body classes
     * e.g. to disable default image hover effect add av-disable-avia-hover-effect
     *
     * @since 4.4.2
     */
    $custom_body_classes = apply_filters( 'avf_custom_body_classes', '' );

    /**
     * @since 4.2.3 we support columns in rtl order (before they were ltr only). To be backward comp. with old sites use this filter.
     */
    $rtl_support            = 'yes' == apply_filters( 'avf_rtl_column_support', 'yes' ) ? ' rtl_columns ' : '';
    
?><!DOCTYPE html>
<html <?php language_attributes(); ?> class="<?php echo "html_{$style} ".$responsive." ".$preloader." ".$av_lightbox." ".$filterable_classes." ".$av_classes_manually ?> ">
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php
/*
 * outputs a rel=follow or nofollow tag to circumvent google duplicate content for archives
 * located in framework/php/function-set-avia-frontend.php
 */
 if (function_exists('avia_set_follow')) { echo avia_set_follow(); }

?>


<!-- mobile setting -->
<?php

if( strpos($responsive, 'responsive') !== false ) { echo '<meta name="viewport" content="width=device-width, initial-scale=1">';  }
?>


<!-- Scripts/CSS and wp_head hook -->
<?php
/* Always have wp_head() just before the closing </head>
 * tag of your theme, or you will break many plugins, which
 * generally use this hook to add elements to <head> such
 * as styles, scripts, and meta tags.
 */

wp_head();

?>

</head>




<body id="top" <?php body_class( $custom_body_classes . ' ' . $rtl_support . $style." ".$avia_config['font_stack']." ".$blank." ".$sidebar_styling); avia_markup_helper(array('context' => 'body')); ?>>

    <?php
    
    /**
     * WP 5.2 add a new function - stay backwards compatible with older WP versions and support plugins that use this hook
     * https://make.wordpress.org/themes/2019/03/29/addition-of-new-wp_body_open-hook/
     *
     * @since 4.5.6
     */
    if( function_exists( 'wp_body_open' ) )
    {
        wp_body_open();
    }
    else
    {
        do_action( 'wp_body_open' );
    }
    
    do_action( 'ava_after_body_opening_tag' );
        
    if("av-preloader-active av-preloader-enabled" === $preloader)
    {
        echo avia_preload_screen();
    }
        
    ?>

    <div id='wrap_all'>

    <?php
    if(!$blank) //blank templates dont display header nor footer
    {
         //fetch the template file that holds the main menu, located in includes/helper-menu-main.php
         get_template_part( 'includes/helper', 'main-menu' );

    } ?>
        
    <div id='main' class='all_colors' data-scroll-offset='<?php echo avia_header_setting('header_scroll_offset'); ?>'>

    <?php
        
        if(isset($avia_config['temp_logo_container'])) echo $avia_config['temp_logo_container'];
        do_action('ava_after_main_container');


کد فایل single.php
کد:
<?php
    if ( !defined('ABSPATH') ){ die(); }
    
    global $avia_config;

    /*
     * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
     */
     get_header();

    $title  = __('Blog - Latest News', 'avia_framework'); //default blog title
    $t_link = home_url('/');
    $t_sub = "";

    if(avia_get_option('frontpage') && $new = avia_get_option('blogpage'))
    {
        $title     = get_the_title($new); //if the blog is attached to a page use this title
        $t_link = get_permalink($new);
        $t_sub =  avia_post_meta($new, 'subtitle');
    }

    if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title(array('heading'=>'strong', 'title' => $title, 'link' => $t_link, 'subtitle' => $t_sub));
    
    do_action( 'ava_after_main_title' );

?>

        <div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>

            <div class='container template-blog template-single-blog '>

                <main class='content units <?php avia_layout_class( 'content' ); ?> <?php echo avia_blog_class_string(); ?>' <?php avia_markup_helper(array('context' => 'content','post_type'=>'post'));?>>

                    <?php
                    /* Run the loop to output the posts.
                    * If you want to overload this in a child theme then include a file
                    * called loop-index.php and that will be used instead.
                    *
                    */
                        get_template_part( 'includes/loop', 'index' );
                  
                        
                        $blog_disabled = ( avia_get_option('disable_blog') == 'disable_blog' ) ? true : false;
                        
                        if(!$blog_disabled)
                        {
                            //show related posts based on tags if there are any
                            get_template_part( 'includes/related-posts');
    
                            //wordpress function that loads the comments template "comments.php"
                            comments_template();
                        }
                    ?>

                <!--end content-->
                </main>

                <?php
                $avia_config['currently_viewing'] = "blog";
                //get the sidebar
                get_sidebar();


                ?>


            </div><!--end container-->

        </div><!-- close default .container_wrap element -->


<?php
        get_footer();
 

Mohammad

مدیر انجمن
پرسنل مدیریت
معمولا در بعد از header قرار میدن. بالای مطالب نمایان میشه. با این یک قطعه کد قالبتون نمیشه جایگزاری کنیم. (باید ازمون و خطا بشه)
 
  • Like
واکنش‌ها[ی پسندها]: sir1

sir1

کاربر عضو
معمولا در بعد از header قرار میدن. بالای مطالب نمایان میشه. با این یک قطعه کد قالبتون نمیشه جایگزاری کنیم. (باید ازمون و خطا بشه)
خود قالب هم برای برید کرامپ کد نویسی شده ولی با RDF نشانه گذاری شده است و توسط گوگل قابل تشخیص نیستند.
نمونه ای از مطالب سایت در گوگل استراکچر:


فایل کد نویسی برید کرامپ ها در قالب پیوست شد لطفا اگر وقت شد یک نگاهی بیندازید. ممنون
 

پیوست‌ها

  • class-breadcrumb.zip
    6.8 کیلوبایت · بازدیدها: 0
بالا