• پایان فعالیت بخشهای انجمن: امکان ایجاد موضوع یا نوشته جدید برای عموم کاربران غیرفعال شده است

نیازمند تغییری کوچک در یک کوِیری (کستوم)

AmirST

Registered User
تاریخ عضویت
10 آپریل 2014
نوشته‌ها
1,382
لایک‌ها
862
محل سکونت
تهران
سلام دوستان
قالبی دارم که از ویژوال کاموسر استفاده میکنه و همونطور که میدونید این افزونه از تمپلیت ها و کویری هایی که در این فایل ها وجود داره برای نمایش محتویات استفاده میکنه. بنده میخواستم در این تمپلیت تغییر کوچکی ایجاد بشه و یه همچین کدی :
PHP:
if ( is_home() ) { query_posts( 'cat=-5,-6' ); }
اضافه بشه که این کویری در صفحه اصلی این دسته بندی های (6 و 5 ) رو نشون نده.
دوستان اگه کمکی از دستشون بر میاد دریغ نکنند
ممنون
کد تمپلیت مد نظر :
کد:
<?php

/* T20 Latest News
----------------------------------------------------*/
vc_map( array(
    "name"        => __("Masonry", "js_composer"),
    "base"        => "masonry",
    "category"    => 'T20',
    "icon"        => "ot-icon-th",
    "description"    => __('Display songs-videos-news-gallery', 'js_composer'),
    "params"    => array(
        array(
                    "type" => "textfield",
                    "heading" => __("Title", "T20"),
                    "param_name" => "title",
            "admin_label" => true
        ),
        array(
                    "type" => "textfield",
                    "heading" => __("Number of post per view", "T20"),
                    "param_name" => "n_posts"
        ),
        array(
            "type"        => "checkbox",
            "heading"    => __("Post Types", "T20"),
            "param_name"    => "cpt_songs",
            "value"        => array(
                __("Songs", "T20") => 'songs'
            )
        ),
        array(
            "type"        => "checkbox",
            "heading"    => '',
            "param_name"    => "cpt_videos",
            "value"        => array(
                __("Videos", "T20") => 'videos'
            )
        ),
        array(
            "type"        => "checkbox",
            "heading"    => '',
            "param_name"    => "cpt_news",
            "value"        => array(
                __("News", "T20") => 'post'
            )
        ),
        array(
            "type"        => "checkbox",
            "heading"    => '',
            "param_name"    => "cpt_gallery",
            "value"        => array(
                __("Gallery", "T20") => 'gallery'
            )
        ),
        array(
            "type"        => "checkbox",
            "heading"    => '',
            "param_name"    => "cpt_events",
            "value"        => array(
                __("Events", "T20") => 'events'
            )
        ),
        array(
            "type"        => "checkbox",
            "heading"    => '',
            "param_name"    => "cpt_artists",
            "value"        => array(
                __("Artists", "T20") => 'artists'
            )
        ),
        array(
            "type"        => "dropdown",
            "heading"    => __("Columns", "T20"),
            "param_name"    => "columns",
            "value"        => array(
                __("4 Columns", "T20") => 'grid_3',
                __("3 Columns", "T20") => 'grid_4',
                __("2 Columns", "T20") => 'grid_6'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => __("Items Badge", "T20"),
            "param_name"    => "badge_mp",
            "value"        => array(
                __("MP3", "T20") => 'MP3'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => '',
            "param_name"    => "badge_vid",
            "value"        => array(
                __("Video", "T20") => 'Video'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => '',
            "param_name"    => "badge_news",
            "value"        => array(
                __("News", "T20") => 'News'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => '',
            "param_name"    => "badge_gal",
            "value"        => array(
                __("Photos", "T20") => 'Photos'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => '',
            "param_name"    => "badge_ev",
            "value"        => array(
                __("Event", "T20") => 'Event'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => '',
            "param_name"    => "badge_art",
            "value"        => array(
                __("Artist", "T20") => 'Artist'
            )
        ),
        array(
            "type"        => "textfield",
            "heading"    => __("Extra Class", "T20"),
            "param_name"    => "extra_class"
        )
    )
) );

/* extract
----------------------------------------------------*/
if (!function_exists('masonry')) {
    function masonry($atts, $content = null) {
        extract(shortcode_atts(array(
            'title'        => '',
            'cpt_songs'    => '',
            'cpt_videos'    => '',
            'cpt_news'    => '',
            'cpt_gallery'    => '',
            'cpt_events'    => '',
            'cpt_artists'    => '',
            'badge_mp'    => '',
            'badge_vid'    => '',
            'badge_news'    => '',
            'badge_gal'    => '',
            'badge_ev'    => '',
            'badge_art'    => '',
            'n_posts'    => '',
            'columns'    => '',
            'extra_class'     => ''
        ), $atts));

        global $post;
        $out  = '';
        $out .= '<div class="masonry_items clearfix '.$extra_class.'">';
        if ($title) {
            $out .= '<h4>'.$title.'</h4><span class="liner"></span>';
        }
        $out .= '<div class="wpb_row wpb_teaser_grid wpb_content_element wpb_grid columns_count_3 columns_count_3 wpb_teaser_grid_songs wpb_teaser_grid_videos"><div class="teaser_grid_container"><ul class="wpb_thumbnails wpb_thumbnails-fluid clearfix" data-layout-mode="masonry">';

        $args = array(
            'post_type'         => array($cpt_songs, $cpt_videos, $cpt_news, $cpt_gallery, $cpt_events, $cpt_artists),   
            'posts_per_page'     => $n_posts,
            'orderby'           => 'date',
            'order'             => 'DESC',
            'post_status'         => 'publish',
            'ignore_sticky_posts'     => true,
        );
        $the_query = new WP_Query( $args );

        if ($the_query->have_posts()) :
            $count = 0; 
            while ($the_query->have_posts()): $the_query->the_post();
            $count++;
            if ( 'songs' === get_post_type( get_the_ID() ) ) :
                $post_type_name = $badge_mp;
            elseif ( 'videos' === get_post_type( get_the_ID() ) ) :
                $post_type_name = $badge_vid;
            elseif ( 'artists' === get_post_type( get_the_ID() ) ) :
                $post_type_name = $badge_art;
            elseif ( 'gallery' === get_post_type( get_the_ID() ) ) :
                $post_type_name = $badge_gal;
            elseif ( 'events' === get_post_type( get_the_ID() ) ) :
                $post_type_name = $badge_ev;
            else :
                $post_type_name = $badge_news;
            endif;

            $out .= '<li class="isotope-item '.$columns.'">';
                $out .= '<a href="'.get_the_permalink().'" title="'.get_the_title().'">';
                $out .= get_the_post_thumbnail($post->ID, 'masonry');
                $out .= '<span class="cat">'.$post_type_name.'</span>';
                $artist_nameaa = get_post_meta($post->ID, 'artist_nameaa', true);
                $artist_name = get_post( $artist_nameaa );
                $out .= '<h3>'.get_the_title().'<small>'.$artist_name->post_title.'</small></h3>';
                $out .= '</a>';
            $out .= '</li>';

        endwhile; endif;
        wp_reset_query();

        $out .= '</ul></div></div>';
        $out .= '</div>';

        wp_enqueue_style('isotope-css');
        wp_enqueue_script( 'isotope' );

        return $out;
    }
}
add_shortcode( 'masonry', 'masonry' );




/**
  * Re-defining vc_row
  */
vc_map( array(
   "name"                    => __("Row", "highthemes"),
   "base"                    => "vc_row",
   "is_container"            => true,
   "icon"                    => "fa-align-justify",
   "show_settings_on_create" => false,
   "description"             => __("Row generator; to create rows, full secsions, parallaxes.","highthemes"),
   "category"                => __('Content', 'highthemes'),
   "params"                  => array(
      array(
         "type" => "checkbox",
         "heading" => __("Full Width Section", "highthemes"),
         "param_name" => "full_width",
         "value" =>Array(__("Yes", "highthemes") => 'yes'),
         "description" => __("Check this box if you would like to make a full width section.", "highthemes")
      ),
      array(
      "type"        => "colorpicker",
      "heading"     => __("Custom Background Color", "wpb"),
      "param_name"  => "bg_color",
      "description" => __("Select your desired custom background color.", "wpb")
    ),
    array(
      "type"        => "attach_image",
      "heading"     => __('Background Image', 'wpb'),
      "param_name"  => "bg_image",
      "description" => __("Select a background image.", "wpb")
    ),
    array(
      "type"       => "dropdown",
      "heading"    => __('Background Repeat', 'wpb'),
      "param_name" => "bg_image_repeat",
      "value"      => array(
                        __("Default", 'wpb')   => '',
                        __('Contain', 'wpb')   => 'contain',
                        __('No Repeat', 'wpb') => 'no-repeat'
                      ),
      "description" => __("Select background image repeat type here.", "wpb"),
      "dependency"  => Array('element' => "bg_image", 'not_empty' => true)
    ),
    array(
       "type"       => "dropdown",
       "heading"    => __("Background Position", "highthemes"),
       "param_name" => "bg_pos",
       "value"      => array(
                        __("Left Top", "highthemes")      => 'left top',
                        __("Left Bottom", "highthemes")   => 'left bottom',
                        __("Left Center", "highthemes")   => 'left center',
                        __("Right Top", "highthemes")     => 'right top',
                        __("Right Bottom", "highthemes")  => 'right bottom',
                        __("Right Center", "highthemes")  => 'right center',
                        __("Center Top", "highthemes")    => 'center top',
                        __("Center Bottom", "highthemes") => 'center bottom',
                        __("Center Center", "highthemes") => 'center center'
                      ),
       "description" => __("Select background image position here.", "highThemes")
    ),     
      array(
         "type"        => "checkbox",
         "heading"     => __("Parallax?", "highthemes"),
         "param_name"  => "parallax",
         "value"       =>Array(__("Yes", "highthemes") => 'yes'),
         "description" => __("Check this box if you would like to have a parallax section.", "highthemes")
      ),         
      array(
         "type"        => "textfield",
         "heading"     => __("Parallax ratio", "highthemes"),
         "param_name"  => "parallax_ratio",
         "value"       => '0.5',
      ),  
      array(
         "type"        => "textfield",
         "heading"     => __("Parallax offset", "highthemes"),
         "param_name"  => "parallax_offset",
         "value"       => '200',
      ),
      array(
         "type"       => "dropdown",
         "heading"    => __("Text Color", "highthemes"),
         "param_name" => "text_color",
         "value"      => array(
                          __("Dark", "highthemes") => 'dark',
                          __("Light", "highthemes") => 'light'
                        ),
         "description" => __("Select text color here. You should select 'dark' where you have light backgrounds and select 'light' where you have dark backgrounds.", "highThemes")
      ),
      array(
         "type"       => "dropdown",
         "heading"    => __("Text Align", "highthemes"),
         "param_name" => "text_align",
         "value"      => array(
                          __("Default", "highthemes") => '',
                          __("Left", "highthemes")    => 'left',
                          __("Right", "highthemes")   => 'right',
                          __("Center", "highthemes")  => 'center'
                        ),
         "description" => __("Select text align.", "highThemes")
      ),              
      array(
         "type"        => "textfield",
         "heading"     => __("Top Padding", "highthemes"),
         "param_name"  => "top_padding",
         "description" => __("Insert top padding value. Please just insert a number and don't include any thing else such as 'px' and ...", "highthemes")
      ),
      array(
         "type"        => "textfield",
         "heading"     => __("Bottom Padding", "highthemes"),
         "param_name"  => "bottom_padding",
         "description" => __("Insert bottom padding value. Please just insert a number and don't include any thing else such as 'px' and ...", "highthemes")
      ),  
    array(
      "type"        => "textfield",
      "heading"     => __('Bottom margin', 'wpb'),
      "param_name"  => "margin_bottom",
      "description" => __("Insert bottom margin value. Please just insert a number and don't include any thing else such as 'px' and ...", "wpb")
      ),
      array(
         "type"        => "textfield",
         "heading"     => __("Extra class name", "highthemes"),
         "param_name"  => "el_class",
         "description" => __("If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your custom css codes.", "highthemes")
      ),
      array(
         "type"        => "textfield",
         "heading"     => __("Extra ID", "highthemes"),
         "param_name"  => "el_id",
         "description" => __("Required field for one page sections", "highthemes")
      )

   ),
"js_view" => 'VcRowView'
) );


/**
* Generate styles
*/
function T20_build_style($bg_image = '', $bg_color = '', $bg_image_repeat = '', $bg_pos ='', $font_color = '', $padding_top = '', $padding_bottom = '', $margin_bottom = '', $text_align='') {
        $has_image = false;
        $style = '';
        if((int)$bg_image > 0 && ($image_url = wp_get_attachment_url( $bg_image, 'large' )) !== false) {
            $has_image = true;
            $style .= "background-image: url(".$image_url.");";
        }
        if(!empty($bg_color)) {
            $style .= 'background-color: '.$bg_color.';';
        }
        if(!empty($bg_pos)) {
            $style .= 'background-position: '.$bg_pos.';';
        }       
        if(!empty($bg_image_repeat) && $has_image) {
            if($bg_image_repeat === 'contain') {
                $style .= "background-repeat:no-repeat;background-size: contain;";
            } elseif($bg_image_repeat === 'no-repeat') {
                $style .= 'background-repeat: no-repeat;';
            }
        }
        if( !empty($font_color) ) {
            $style .= 'color: '.$font_color.';';
        }
        if( $padding_top != '' ) {
            $style .= 'padding-top: '. $padding_top.'px;';
        }
        if( $padding_bottom != '' ) {
            $style .= 'padding-bottom: '. $padding_bottom.'px;';
        }       
        if( $margin_bottom != '' ) {
            $style .= 'margin-bottom: '.$margin_bottom.'px;';
        }
        if( $text_align != '' ) {
            $style .= 'text-align: '.$text_align.';';
        }       
        return $style;
    }


/* extract
----------------------------------------------------*/
if (!function_exists('vc_row')) {
    function vc_row($atts, $content = null) {
        $output = $el_class = $bg_image = $bg_color = $bg_image_repeat = $font_color = $padding = $margin_bottom = '';
        extract(shortcode_atts(array(
            'full_width'        => 'no',
            'bg_pos'        => '',
            'parallax'        => '',
            'parallax_offset'        => '',
            'parallax_ratio'        => '',
            'text_color'        => '',
            'top_padding'        =>'',
            'bottom_padding'    =>'',  
            'el_class'        => '',
            'el_id'            => '',
            'bg_image'        => '',
            'bg_color'        => '',
            'bg_image_repeat'    => '',
            'margin_bottom'        => '',
            'text_align'        =>''
        ), $atts));

        $parallax_class = ($parallax =='yes') ? 'parallax ': '';
        $parallax_settings = ($parallax =='yes') ? ' data-stellar-background-ratio="' . $parallax_ratio . '" data-stellar-vertical-offset="' . $parallax_offset . '"' : '';
        $text_color = ($text_color =='light') ? 'light ': 'dark ';
        $full_width = ($full_width =='yes') ? ' full-width-section clearfix' : '';

        $style = T20_build_style($bg_image, $bg_color, $bg_image_repeat, $bg_pos, '', $top_padding, $bottom_padding, $margin_bottom, $text_align);

        $out  = '';
        $out .= '<div id="'.$el_id.'" style="'.$style.'" class="' . $text_color . $full_width . $el_class. ' clearfix T20-row '.$parallax_class.'" '.$parallax_settings.'>';
        $out .= wpb_js_remove_wpautop($content);
        $out .= '</div>';

        wp_enqueue_style( 'js_composer_front' );
        wp_enqueue_script( 'wpb_composer_front_js' );
        wp_enqueue_style('js_composer_custom_css');

        return $out;
    }
}
add_shortcode( 'vc_row', 'vc_row' );
 

saeedagha2010

Registered User
تاریخ عضویت
21 فوریه 2013
نوشته‌ها
135
لایک‌ها
85
محل سکونت
صندلی
از افزونه hide categories هم می تونید استفاده کنید و دسته های مورد نظر رو در مکان مورد نظر خود مخفی کنید یا در همین کوئری که دادید به جای
کد:
 "category"    => 'T20',
از این استفاده کنید
کد:
"category" => 'T20, -5, -6',
 

AmirST

Registered User
تاریخ عضویت
10 آپریل 2014
نوشته‌ها
1,382
لایک‌ها
862
محل سکونت
تهران
از افزونه hide categories هم می تونید استفاده کنید و دسته های مورد نظر رو در مکان مورد نظر خود مخفی کنید یا در همین کوئری که دادید به جای
کد:
 "category"    => 'T20',
از این استفاده کنید
کد:
"category" => 'T20, -5, -6',
سلام ممنون بابت راهنمایی و توجه
افزونه معرفی شده فقط با کویری اصلی وردپرس که همون پست ها باشن کار میکنه و نمیشه توش کویری های اضافه خود قالب رو انتخاب کرد.
اما کدی که دادید استفاده کردم اما جواب نداد ... فایل قالب هم پیوست شد در صورت نیاز :
http://linkzquickz.com/new/remix15.zip


پ ن : دوستان میخوام سانگ ها و ویدیو ها و پست های یه سری از دسته ها توی صفحه اصلی نمایش داده نشن / توی صفحه اصلی از المنت mansory استفاده میشه.
 

saeedagha2010

Registered User
تاریخ عضویت
21 فوریه 2013
نوشته‌ها
135
لایک‌ها
85
محل سکونت
صندلی

AmirST

Registered User
تاریخ عضویت
10 آپریل 2014
نوشته‌ها
1,382
لایک‌ها
862
محل سکونت
تهران
استباه شد از ای دی دسته باید استفاده کنید مثلا به جای
کد:
 "category"    => 'T20',
کد:
"cat"    =>  '13,-5,-6',
تا نوشته های ای دی دسته 13 نمایش داده بشه و 5 و 6 نشان داده نشه (13مثلا ای ید دسته T20 هست)
لیتنک منبع:
http://codex.wordpress.org/Function_Reference/query_posts#Exclude_Categories_From_Your_Home_Page
ممنون. ممکنه راهنمایی کنید از این کد کجا استفاده کنم . منبع رو مطالعه کردم اما باز هم متوجه نشدم در کجای قالب باید از این آرایه استفاده کنم.
اگر امکان داره زحمتش رو روی قالب بفرمایید هزینش هم پرداخت میشه.
 
بالا