Wsparcie » Zaawansowane » Problem z wyświetlaniem pojedynczych postów – shortcodes

  • Witam serdecznie,

    Projekt już mnie naprawdę irytuje i nie mam siły ciągle szukać rozwiązania problemów. Właściciel strony kupił sobie gotowy szablon, a ja się muszę ze wszystkim użerać. W tym momencie muszę zrobić „własną” stronę główną. Korzystam z funkcji stron w WP i shortcodes, napisałem funkcję dwóch własnych shortcodes:

    function mainpage2($atts, $content = null) {
    
    $strr = do_shortcode($content);
    	        $tekst = '<div class="cat_title"><h2>' . $strr . '</h2><div class="clear"></div></div>';
    				return $tekst;
    
    	}
    add_shortcode('nazwakategorii', 'mainpage2');
    
    function mainpage1($atts, $content = null) {
    
    $rss = do_shortcode($content);
     $args = array( 'numberposts' => 1, 'category' => $rss );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post);
    $eee = _e('Czytaj więcej', 'tfuse');
    					$tekst = '<div class="post-item"><h2><a href="' . the_permalink() . '">' . the_title() . '</a></h2><div class="post-meta">
    					<em>' .  _e('przez', 'tfuse') . '<span class="author">' . the_author_posts_link() . '</span> &nbsp;|&nbsp;
    						<a href="' . comments_link() . '" class="link-comments">
    							' . comments_number('0 komentarzy', '1 komentarz', '2 komentarze', '3 komentarze', '4 komentarze', '% komenatarzy') . '
    						</a>
    					</em>
    
    				</div>
    
    				<div class="entry">' . the_excerpt() .'
    					<div class="clear"></div>
    				</div>
    
    				<a class="link-more" href="' . the_permalink() . '" >
    					' .  $eee . '
    				</a>
    			</div>';
    			 endforeach;
    	return $tekst;
    	}
    add_shortcode('postglowna', 'mainpage1');

    Do odpowiedniej strony dodałem:

    [nazwakategorii]Edytorial[/nazwakategorii]
    [postglowna]4[/postglowna]

    I niestety nie wyświetla mi nawet w połowie tak jak powinno -> http://magazyn.linuxpl.info/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • Temat ‘Problem z wyświetlaniem pojedynczych postów – shortcodes’ jest zamknięty na nowe odpowiedzi.