Arizz
Odpowiedź forum utworzona
-
Forum: Motywy
W odpowiedzi na: Kategorie – wyświetlanie listy i zawartości.Problem chyba polega głównie na tym, że wyświetlanie kategorii na stronie głównej jako grid jest zastosowane w formie shortcode tak jak w kodzie który podałem wyżej, a sposób wyświetlania kategorii domyślnie chyba nie obsługuje tego. To wszystko moje domysły więc może ktoś mnie z błędu wyprowadzi, ale na chwilę obecną wg mnie trzeba „uruchomić” ten shortcode albo w pliku category.php albo loop-blog.php. Niestety pojęcia nie mam którą jego część i w które miejsce wstawić. Wrzucę jeszcze jak wygląda plik posts-grid który definiuje wygląd tych szarych cegiełek. Jakby ktoś coś to będę wdzięczny, póki co uruchamiam bloga tak jak jest i będę czekał na jakąś podpowiedź.
<?php /** * Post Grid * */ if (!function_exists('posts_grid_shortcode')) { function posts_grid_shortcode( $atts, $content = null, $shortcodename = '' ) { extract(shortcode_atts(array( 'type' => 'post', 'category' => '', 'custom_category' => '', 'tag' => '', 'columns' => '3', 'rows' => '3', 'order_by' => 'date', 'order' => 'DESC', 'thumb_width' => '370', 'thumb_height' => '250', 'meta' => '', 'excerpt_count' => '15', 'link' => 'yes', 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'custom_class' => '' ), $atts)); $spans = $columns; $rand = rand(); // columns switch ($spans) { case '1': $spans = 'span12'; break; case '2': $spans = 'span6'; break; case '3': $spans = 'span4'; break; case '4': $spans = 'span3'; break; case '6': $spans = 'span2'; break; } // check what order by method user selected switch ($order_by) { case 'date': $order_by = 'post_date'; break; case 'title': $order_by = 'title'; break; case 'popular': $order_by = 'comment_count'; break; case 'random': $order_by = 'rand'; break; } // check what order method user selected (DESC or ASC) switch ($order) { case 'DESC': $order = 'DESC'; break; case 'ASC': $order = 'ASC'; break; } // show link after posts? switch ($link) { case 'yes': $link = true; break; case 'no': $link = false; break; } global $post; global $my_string_limit_words; $numb = $columns * $rows; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array( 'post_type' => $type, 'category_name' => $category, $type . '_category' => $custom_category, 'tag' => $tag, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters ); $posts = get_posts($args); $i = 0; $count = 1; $output_end = ''; $countul = 0; if ($numb > count($posts)) { $output_end = '</ul>'; } $output = '<ul class="posts-grid row-fluid unstyled '. $custom_class .' ul-item-'.$countul.'">'; foreach ( $posts as $j => $post ) { $post_id = $posts[$j]->ID; //Check if WPML is activated if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { global $sitepress; $post_lang = $sitepress->get_language_for_element( $post_id, 'post_' . $type ); $curr_lang = $sitepress->get_current_language(); // Unset not translated posts if ( $post_lang != $curr_lang ) { unset( $posts[$j] ); } // Post ID is different in a second language Solution if ( function_exists( 'icl_object_id' ) ) { $posts[$j] = get_post( icl_object_id( $posts[$j]->ID, $type, true ) ); } } setup_postdata($posts[$j]); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'full' ); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $mediaType = get_post_meta($post_id, 'tz_portfolio_type', true); $prettyType = 0; if ($count > $columns) { $count = 1; $countul ++; $output .= '<ul class="posts-grid row-fluid unstyled '. $custom_class .' ul-item-'.$countul.'">'; } $output .= '<li class="'. $spans .' list-item-'.$count.'">'; if(has_post_thumbnail($post_id) && $mediaType == 'Image') { $prettyType = 'prettyPhoto-'.$rand; $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="'.$url.'" title="'.get_the_title($post_id).'" rel="' .$prettyType.'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post_id).'" />'; $output .= '<span class="zoom-icon"></span></a></figure>'; } elseif ($mediaType != 'Video' && $mediaType != 'Audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post_id); $images = get_children( array( 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1 ) ); if ( $images ) { $k = 0; //looping through the images foreach ( $images as $attachment_id => $attachment ) { $prettyType = "prettyPhoto-".$rand ."[gallery".$i."]"; //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); // returns an array $img = aq_resize( $image_attributes[0], $thumb_width, $thumb_height, true ); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ( $k == 0 ) { if (has_post_thumbnail($post_id)) { $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="'.$image_attributes[0].'" title="'.get_the_title($post_id).'" rel="' .$prettyType.'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post_id).'" />'; } else { $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="'.$image_attributes[0].'" title="'.get_the_title($post_id).'" rel="' .$prettyType.'">'; $output .= '<img src="'.$img.'" alt="'.get_the_title($post_id).'" />'; } } else { $output .= '<figure class="featured-thumbnail thumbnail" style="display:none;">'; $output .= '<a href="'.$image_attributes[0].'" title="'.get_the_title($post_id).'" rel="' .$prettyType.'">'; } $output .= '<span class="zoom-icon"></span></a></figure>'; $k++; } } elseif (has_post_thumbnail($post_id)) { $prettyType = 'prettyPhoto-'.$rand; $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="'.$url.'" title="'.get_the_title($post_id).'" rel="' .$prettyType.'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post_id).'" />'; $output .= '<span class="zoom-icon"></span></a></figure>'; } } else { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail thumbnail"><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post_id).'" />'; $output .= '</a></figure>'; } $output .= '<div class="clear"></div>'; $output .= '<h4><title="'.get_the_title($post_id).'">'; $output .= get_the_title($post_id); $output .= '</a></h4>'; if ($meta == 'yes') { // begin post meta $output .= '<div class="post_meta">'; // post category $output .= '<span class="post_category">'; if ($type!='' && $type!='post') { $terms = get_the_terms( $post_id, $type.'_category'); if ( $terms && ! is_wp_error( $terms ) ) { $out = array(); $output .= '<em>Posted in </em>'; foreach ( $terms as $term ) $out[] = '<a href="' .get_term_link($term->slug, $type.'_category') .'">'.$term->name.'</a>'; $output .= join( ', ', $out ); } } else { $categories = get_the_category($post_id); if($categories){ $out = array(); $output .= '<em>Posted in </em>'; foreach($categories as $category) $out[] = '<a href="'.get_category_link($category->term_id ).'" title="'.$category->name.'">'.$category->cat_name.'</a> '; $output .= join( ', ', $out ); } } $output .= '</span>'; // post date $output .= '<span class="post_date">'; $output .= '<time datetime="'.get_the_time('Y-m-d\TH:i:s', $post_id).'">' .get_the_date(). '</time>'; $output .= '</span>'; // post author $output .= '<span class="post_author">'; $output .= '<em> by </em>'; $output .= '<a href="'.get_author_posts_url(get_the_author_meta( 'ID' )).'">'.get_the_author_meta('display_name').'</a>'; $output .= '</span>'; // post comment count $num = 0; $queried_post = get_post($post_id); $cc = $queried_post->comment_count; if( $cc == $num || $cc > 1 ) : $cc = $cc.' Comments'; else : $cc = $cc.' Comment'; endif; $permalink = get_permalink($post_id); $output .= '<span class="post_comment">'; $output .= '<a href="'. $permalink . '" class="comments_link">' . $cc . '</a>'; $output .= '</span>'; $output .= '</div>'; // end post meta } $output .= cherry_get_post_networks(array('post_id' => $post_id, 'display_title' => false, 'output_type' => 'return')); if($excerpt_count >= 1){ $output .= '<p class="excerpt">'; $output .= wp_trim_words($excerpt,$excerpt_count); $output .= '</p>'; } if($link){ $output .= '<a href="'.get_permalink($post_id).'" class="btn btn-primary" title="'.get_the_title($post_id).'">'; $output .= $link_text; $output .= '</a>'; } $output .= '</li>'; if ($j == count($posts)-1) { $output .= $output_end; } if ($count % $columns == 0) { $output .= '</ul><!-- .posts-grid (end) -->'; } $count++; $i++; } // end for wp_reset_postdata(); // restore the global $post variable $output = apply_filters( 'cherry_plugin_shortcode_output', $output, $atts, $shortcodename ); return $output; } add_shortcode('posts_grid', 'posts_grid_shortcode'); }?>
Pozdrawiam!
Forum: Motywy
W odpowiedzi na: Kategorie – wyświetlanie listy i zawartości.Motyw jest chyba raczej mało znany, oto on:
http://www.templatemonster.com/wordpress-themes/49250.html
Nie jestem właśnie w stanie określić który to plik. Sekcję najnowsze przepisy na stronie głównej wygenerowałem poprzez dodanie poniższego kodu do strony „Home” w panelu admina, bez ingerencji w pliki:
[custom_title title_text="NAJNOWSZE PRZEPISY" link_text="ZOBACZ WSZYSTKIE" link_url="http://zakuchana.pl/nowe/"] [posts_grid category="nowe" columns="3" rows="4" order_by="date" order="DESC" thumb_width="330" thumb_height="240" meta="no" excerpt_count="0" link="yes" link_text="przejdź do przepisu"]
Kod pliku który podałem wcześniej jest własnie z pliku category.php
Forum: Motywy
W odpowiedzi na: Kategorie – wyświetlanie listy i zawartości.Ok, problem nr 3 rozwiązany. Wyłączyłem wyświetlanie okruszków w szablonie, a w pliku „title.php” wyrzuciłem wyrażenie „Category Archives”. Teraz wyświetla się sama nazwa kategorii i tak może być.
Zostaje tylko kwestia wyświetlania wpisów kategorii tak jak kafelki na stronie głównej. Niestety nie mam pojęcia jak tego dokonać, a moja „wiedza” o kodowaniu jest dość znikoma. Jeżeli ktoś byłby tak dobry i pokazał jaki kawałek kodu należy wrzucić do pliku category.php to będę bardzo wdzięczny. Poniżej wygląd mojego pliku category.php:
<?php get_header(); ?> <div class="motopress-wrapper content-holder clearfix"> <div class="container"> <div class="row"> <div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-wrapper-file="category.php" data-motopress-wrapper-type="content"> <div class="row"> <div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-title.php"> <?php get_template_part("static/static-title"); ?> </div> </div> <div class="row"> <div class="<?php echo cherry_get_layout_class( 'content' ); ?> <?php echo of_get_option('blog_sidebar_pos'); ?>" id="content" data-motopress-type="loop" data-motopress-loop-file="loop/loop-blog.php"> <?php get_template_part("loop/loop-blog"); ?> </div> <div class="<?php echo cherry_get_layout_class( 'sidebar' ); ?> sidebar" id="sidebar" data-motopress-type="static-sidebar" data-motopress-sidebar-file="sidebar.php"> <?php get_sidebar(); ?> </div> </div> </div> </div> </div> </div> <?php get_footer(); ?>
Forum: Motywy
W odpowiedzi na: Kategorie – wyświetlanie listy i zawartości.1. Ok, pobawię się, aczkolwiek koder ze mnie marny ale może skopiuję jakoś kawałek kodu ze strony głównej.
2. No tak, taki banał że aż mi głupio. Dzięki.
3. Właśnie ani w category.php ani w archive.php nie ma wyrażenia „Category Archives”, szukałem też w innych plikach które na logike mogły by być z tym związane ale też bez powodzenia. Czyli nie ma innej opcji? W którymś pliku po prostu musi gdzieś widnieć to wyrażenie i trzeba je usunąć?