PDA

View Full Version : سوال: مشکل در کوِیری یک تمپلیت وردپرسی -فوری



amir-st
جمعه 29 اسفند 1393, 17:51 عصر
سلام دوستان
قالبی دارم که از تمپلیت ها و کویری هایی که در این فایل وجود داره برای نمایش محتویات استفاده میکنه. بنده میخواستم در این تمپلیت تغییر کوچکی ایجاد بشه و یه همچین کدی :
PHP:
if ( is_home() ) { query_posts( 'cat=6' ); }

اضافه بشه که این کویری در صفحه اصلی این دسته بندی (6) نشون بده.
دوستان اگه کمکی از دستشون بر میاد دریغ نکنند خیلی بد گیر کردم . اگه فکر میکنید به چیز دیگه ای نیازه بفرمایید هزینه هم اگه داشته باشه میدم فقط سریع کمک کنید.:افسرده:

ممنون
کد تمپلیت مد نظر :
کد:


<?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' );

vahid78
جمعه 29 اسفند 1393, 18:35 عصر
بدون نیاز به هیچ تغییری این کد به شما کمک میکنه


<?php $args = array(
'category' => '6',
);
$posts_array = get_posts( $args ); ?>

amir-st
شنبه 01 فروردین 1394, 22:57 عصر
بدون نیاز به هیچ تغییری این کد به شما کمک میکنه


<?php $args = array(
'category' => '6',
);
$posts_array = get_posts( $args ); ?>

ممنون از راهنماییتون . همونطور که توی کد مشاهده کردید خودش args تعریف کرده و اگه از این به صورت جدا گانه بعد از args تعریف شده استفاده کنم فقط پست ها رو نشون میده (درصورتی که نیا هست cpt_songs و cpt_videos و .... هم نشان داده بشه.
اما اگه کتگوری به args موجود اضافه کنیم عمل نمیکنه.
لطفا راهنمایی کنید خیلی در گیرشم. لینک قالب هم اگه لازم بود :http://prefiles.com/2amqtlduf2ft/remix15.rar

amir-st
یک شنبه 02 فروردین 1394, 01:37 صبح
واقعا به کمکتون نیاز دارم. اگه امکانش هست برای هر دوستی بگه دسترسی بدم بیاد چک کنه.. فکر نمیکنم اونقدری که دوستان فکر میکنن ساده باشه .. فکر کنم چون داره چند نوع پست رو توی یه کویری نمایش میده برای دادن کتگوری باید از ایف استفاده بشه (البته من آشنایی کمی دارم) .. لطفا هر کس میتونه کمکی بکنه دریغ نکنه. :ناراحت:

amir-st
یک شنبه 02 فروردین 1394, 12:22 عصر
لطفا کمک کنید.

amir-st
دوشنبه 03 فروردین 1394, 14:20 عصر
لطفا کمک کنید