رفتن به مطلب

تداخل افزونه ی جلالی با ویژوال کامپوزر


پست های پیشنهاد شده

سلام به همه دوستان

من میخوام با پست تایپی که درست کردم در قسمتی از قالبمم پیغام های دلخوام رو نشون بدم که توش از کامپوزر استفاده کردم، همه چیز صحیح کار میکنه تا زمانی که افزونه جلالی رو فعال نکردم  خطای (APPCRASH) می ده آپاچی. کسی می تونه کمکم کنه حس میکنم باید به یه شکل دیگه کوئری رو بنویسم ولی فقط با WP_Query به صورت درست نمایش داده میشه (وقتی افزونه جلالی غیر فعاله)

کدم هم به صورت زیر هستش:

<?php
if( ! function_exists( 'pl_notification_Bar' )) {
    function pl_notification_Bar($position = 'top')
    {

        $args = array(
            'post_type' => 'Notification_Bar',
            'meta_query' => array(
                array(
                    'relation' => 'AND',
                    'pl_active_notification' => array(
                        'key' => 'pl_active_notification',
                    ),
                    'pl_display_area' => array(
                        'key' => 'pl_display_area',
                        'value' => $position,
                        'compare' => 'LIKE',
                    ),
                )
            ),
            'orderby' => array(
                'pl_active_notification' => 'desc',
                'pl_display_area' => 'desc',
            ),
        );
        $loop = new WP_Query($args);
        if ($loop->have_posts()):
            echo '<div class="box_notification_bar">';
            while ($loop->have_posts()) : $loop->the_post();

                $mob_notification = get_post_meta(get_the_ID(), 'pl_display_mob_notification', true);
                if ($mob_notification != 'on') {
                    $mob_notification = ' d-none d-md-flex';
                }
                if(wp_is_mobile() && $mob_notification != 'on') {
                    return false;
                }

                $rand = wp_rand();
                $area = get_post_meta(get_the_ID(), 'pl_display_area', true);
                $method = get_post_meta(get_the_ID(), 'pl_display_method', true);
                $remove = get_post_meta(get_the_ID(), 'pl_close_button_notification', true);


                if ($remove == 'on') {
                    $method .= ' yt-close';
                }


                ?>
                <div class="site-content yt-vc-wrapper pl_notification_bar yt-<?php echo $method.$mob_notification;
                echo ' ' . $area ?>" id="yt-<?php echo $rand; ?>">
                    <div class="vc-content-area yt-single-page container d-flex">
                        <?php if ($remove == 'on') {
                            echo '<div class="box_close yt-align-items-center"><div class="pl_close fi-close1"></div></div>';
                        } ?>
                        <main class="site-main yt-align-items-center w-100">
                            <div class="w-100 d-block">
                                <?php
                                vc_custom_css(get_the_ID());
                                esc_html(the_content());
                                ?>
                            </div>
                        </main>
                    </div>
                </div>
                <?php
            endwhile;
            echo '</div>';
        endif;
        wp_reset_query();

    }
}

 

ویرایش شده توسط reza_yki
لینک به ارسال

سلام؛ وقتتون بخیر

من پیامتون رو درست متوجه نشدم؛ شما یک نوع نوشته ی خاص ایجاد کردید و قصد دارید تا محتوای خودتون رو با ویژوال کامپوزر طراحی کنید و بعد از اون توی بخش دلخواه خودتون نمایش بدید؟

اگر خواسته ی شما این هست، این روش رو امتحان کنید!

کد های زیر رو به فایل توابع (function.php) پوسته وردپرس خودتون اضافه کنید :

// Themei.ir custom post type (CPT) function
function custom_post_type() {
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Notifactions', 'Post Type General Name', 'themei_ir' ),
        'singular_name'       => _x( 'Notifaction', 'Post Type Singular Name', 'themei_ir' ),
        'menu_name'           => __( 'Notifactions', 'themei_ir' ),
        'parent_item_colon'   => __( 'Parent Notifaction', 'themei_ir' ),
        'all_items'           => __( 'All Notifactions', 'themei_ir' ),
        'view_item'           => __( 'View Notifaction', 'themei_ir' ),
        'add_new_item'        => __( 'Add New Notifaction', 'themei_ir' ),
        'add_new'             => __( 'Add New', 'themei_ir' ),
        'edit_item'           => __( 'Edit Notifaction', 'themei_ir' ),
        'update_item'         => __( 'Update Notifaction', 'themei_ir' ),
        'search_items'        => __( 'Search Notifaction', 'themei_ir' ),
        'not_found'           => __( 'Not Found', 'themei_ir' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'themei_ir' ),
    );
// Set other options for Custom Post Type
    $args = array(
        'label'               => __( 'notifactions', 'themei_ir' ),
        'description'         => __( 'You Can See Notifactions Here', 'themei_ir' ),
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        // You can associate this CPT with a taxonomy or custom taxonomy. 
        'taxonomies'          => array( 'noftifaction' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
    );
     
    // Themei.iR - Registering your Custom Post Type
    register_post_type( 'notifactions', $args );
 
}
add_action( 'init', 'custom_post_type', 0 );

با اضافه کردن کد های بالا، شما نوع نوشته ی دلخواه خودتون رو به قالبتون اضافه میکنید.

حالا بعد از اینکه نوع نوشته ی دلخواه خودتون رو ایجاد کردید، باید مطالب خودتون رو نمایش بدید.

برای نمایش مطالب؛ کد زیر رو در فایل function.php قرار بدید :

//Themei.iR Displaying Custom Post Types on The Front Page

add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
	function add_my_post_types_to_query( $query ) {
    	if ( is_home() && $query->is_main_query() )
			$query->set( 'post_type', array( 'post', 'notifactions' ) );
    	return $query;
	}

اگر هم میخواید که محتوا رو با کوئری نمایش بدید؛ از کد زیر استفاده کنید :

<?php 
$args = array( 'post_type' => 'notifactions', 'posts_per_page' => 10 );
$the_query = new WP_Query( $args ); 
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?> 
</div>
<?php wp_reset_postdata(); ?>
<?php else:  ?>
<p><?php _e( 'Sorry, no posts matched your criteria.', 'themei_ir'); ?></p>
<?php endif; ?>

 

لطفا توجه کنید که من توی این کد ها یه نوع نوشته ی جدید با عنوان "Notifactions" ایجاد کردم.
لینک دسترسی به این محتوا توی سایت شما به صورت زیر هست :

https://themei.ir/?post_type=notifactions
Or
https://themei.ir/notifactions

بجای themei.ir آدرس وبسایت خودتون رو قرار بدید.

این کد رو تست کنید و نتیجه رو اعلام کنید!

لینک به ارسال
در در 4/16/2019 at 13:17، Ehsan Np گفته است :

سلام؛ وقتتون بخیر

من پیامتون رو درست متوجه نشدم؛ شما یک نوع نوشته ی خاص ایجاد کردید و قصد دارید تا محتوای خودتون رو با ویژوال کامپوزر طراحی کنید و بعد از اون توی بخش دلخواه خودتون نمایش بدید؟

اگر خواسته ی شما این هست، این روش رو امتحان کنید!

کد های زیر رو به فایل توابع (function.php) پوسته وردپرس خودتون اضافه کنید :


// Themei.ir custom post type (CPT) function
function custom_post_type() {
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Notifactions', 'Post Type General Name', 'themei_ir' ),
        'singular_name'       => _x( 'Notifaction', 'Post Type Singular Name', 'themei_ir' ),
        'menu_name'           => __( 'Notifactions', 'themei_ir' ),
        'parent_item_colon'   => __( 'Parent Notifaction', 'themei_ir' ),
        'all_items'           => __( 'All Notifactions', 'themei_ir' ),
        'view_item'           => __( 'View Notifaction', 'themei_ir' ),
        'add_new_item'        => __( 'Add New Notifaction', 'themei_ir' ),
        'add_new'             => __( 'Add New', 'themei_ir' ),
        'edit_item'           => __( 'Edit Notifaction', 'themei_ir' ),
        'update_item'         => __( 'Update Notifaction', 'themei_ir' ),
        'search_items'        => __( 'Search Notifaction', 'themei_ir' ),
        'not_found'           => __( 'Not Found', 'themei_ir' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'themei_ir' ),
    );
// Set other options for Custom Post Type
    $args = array(
        'label'               => __( 'notifactions', 'themei_ir' ),
        'description'         => __( 'You Can See Notifactions Here', 'themei_ir' ),
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        // You can associate this CPT with a taxonomy or custom taxonomy. 
        'taxonomies'          => array( 'noftifaction' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
    );
     
    // Themei.iR - Registering your Custom Post Type
    register_post_type( 'notifactions', $args );
 
}
add_action( 'init', 'custom_post_type', 0 );

با اضافه کردن کد های بالا، شما نوع نوشته ی دلخواه خودتون رو به قالبتون اضافه میکنید.

حالا بعد از اینکه نوع نوشته ی دلخواه خودتون رو ایجاد کردید، باید مطالب خودتون رو نمایش بدید.

برای نمایش مطالب؛ کد زیر رو در فایل function.php قرار بدید :


//Themei.iR Displaying Custom Post Types on The Front Page

add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
	function add_my_post_types_to_query( $query ) {
    	if ( is_home() && $query->is_main_query() )
			$query->set( 'post_type', array( 'post', 'notifactions' ) );
    	return $query;
	}

اگر هم میخواید که محتوا رو با کوئری نمایش بدید؛ از کد زیر استفاده کنید :


<?php 
$args = array( 'post_type' => 'notifactions', 'posts_per_page' => 10 );
$the_query = new WP_Query( $args ); 
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?> 
</div>
<?php wp_reset_postdata(); ?>
<?php else:  ?>
<p><?php _e( 'Sorry, no posts matched your criteria.', 'themei_ir'); ?></p>
<?php endif; ?>

 

لطفا توجه کنید که من توی این کد ها یه نوع نوشته ی جدید با عنوان "Notifactions" ایجاد کردم.
لینک دسترسی به این محتوا توی سایت شما به صورت زیر هست :


https://themei.ir/?post_type=notifactions
Or
https://themei.ir/notifactions

بجای themei.ir آدرس وبسایت خودتون رو قرار بدید.

این کد رو تست کنید و نتیجه رو اعلام کنید!

من هم کارایی که شما گفته بودید رو انجام داده بودم ولی افاقه نکرد تا اینکه به جای while از foreach استفاده کردم مشکل در کمال ناباوری حل شد :|

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...