Wsparcie » Motywy » Kilka całych wpisów następne tylko tytuły jako odnośniki.

  • Witam,

    Szukam, próbuje i mi nie wychodzi cały dzień dlatego z załamanymi rękoma proszę was o pomoc.

    Mam jedną kategorię dla wpisów (aktualności, ID 1) i chciałbym je wyświetlić w taki sposób aby na początek na górze pojawiły mi się 3 wpisy z opisem (nazwa wpisu, opis skrócony, oraz klawisz czytaj więcej) a poniżej 7 odnośników do pozostałych (nazwy wpisów) – bez treści i bez klawisza czytaj więcej, oczywiście poniżej paginacja będzie przełączać na kolejne strony.

    Ogólnie paginacje, klawisz czytaj więcej, opis skrócony na listach wpisów już mam zrobione ale niestety nie wiem jak usunąć opis i czytaj więcej dla starczych niż ostatnie 3.

    Znalazłem takie coś ale niestety nie chce mi to zadziałąć:

    Templatka na której bazuje to: twentytwelve

    A kod z pliku content.php poniżej:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    		<div class="featured-post">
    			<?php _e( 'Featured post', 'twentytwelve' ); ?>
    		</div>
    		<?php endif; ?>
    
    		<header class="entry-header">
    			<?php if ( ! post_password_required() && ! is_attachment() ) :
    				the_post_thumbnail();
    			endif; ?>
    
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>
    			<h1 class="entry-title">
    				<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</h1>
    			<?php endif; // is_single() ?>
    
    		</header><!-- .entry-header -->
    
    		<?php if ( is_search() ) : // Only display Excerpts for Search ?>
    		<div class="entry-summary">
    			<?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    
    		</div><!-- .entry-summary -->
    
    		<?php elseif ( is_single() ) : ?>
    
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    
    		</div><!-- .entry-content -->
    
    		<?php else : ?>
    
    		<div class="entry-summary">
    			<?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-summary -->
    
    		<?php endif; ?>
    
    	</article><!-- #post -->

    Paginacja i excerpt w pliku functions.php wygląda tak:

    function custom_wp_trim_excerpt($text) {
    $raw_excerpt = $text;
    if ( '' == $text ) {
        //Retrieve the post content.
        $text = get_the_content('');
    
        //Delete all shortcode tags from the content.
        $text = strip_shortcodes( $text );
    
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
    
        $allowed_tags = '<p>,<a>,<em>,<strong>,<img>';
        $text = strip_tags($text, $allowed_tags);
    
        $excerpt_word_count = 142; /*** MODIFY THIS. change the excerpt word count to any integer you like.***/
        $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); 
    
    $excerpt_end = '<br /><div class="booton_wiecej_left"></div><div class="booton_wiecej_right"><a href="'. get_permalink($post->ID) . '">' . 'Czytaj</a></div>';
        $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
    
        $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
        if ( count($words) > $excerpt_length ) {
            array_pop($words);
            $text = implode(' ', $words);
            $text = $text . $excerpt_more;
        } else {
            $text = implode(' ', $words);
        }
    }
    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
    }
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_wp_trim_excerpt');
    
    function paginate() {
    	global $wp_query, $wp_rewrite;
    	$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
    
    	$pagination = array(
    		'base' => @add_query_arg('page','%#%'),
    		'format' => '',
    		'total' => $wp_query->max_num_pages,
    		'current' => $current,
    		'show_all' => true,
    		'prev_next'    => True,
    		'type' => 'list',
    		'next_text' => '<img src="/wp-content/themes/twentytwelve-child/img/pagina_next.png" align="middle" height="22" width="22">',
    		'prev_text' => '<img src="/wp-content/themes/twentytwelve-child/img/pagina_previ.png" align="middle" height="22" width="22">'
    		);
    
    	if( $wp_rewrite->using_permalinks() )
    		$pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
    
    	if( !empty($wp_query->query_vars['s']) )
    		$pagination['add_args'] = array( 's' => get_query_var( 's' ) );
    
    	echo paginate_links( $pagination );
    }

    Bardzo wdzięczny będą za pomoc w tej sprawie.

Viewing 1 replies (of 1 total)
  • Musisz tu zrobic dwie pętle. Pierwsza pętla wysiwtla 3 wspisy druga 7, no i paginacja na końcu.

    Robiłem kiedyś coś podobnego. Podrzucę Ci kod to sobie będziesz eksperymenował. Nie jest to dokładnie to co chcesz ALE będziesz miał wskazówke jak to zrobić.

    http://pastebin.com/uGE6nHg4

    Właściwie to jest to na podstawie Dokumentacji z Kodeksa WP. Więc pierwsze miejsce jakie powinieneś odwiedzić to własnie ona: https://codex.wordpress.org/The_Loop

Viewing 1 replies (of 1 total)
  • Temat ‘Kilka całych wpisów następne tylko tytuły jako odnośniki.’ jest zamknięty na nowe odpowiedzi.