• Resolved mYrAn

    (@myran)


    Hello!

    Im building a site for a client and im making i widget to display “news” (posts from a specified category) on the firstpage. However, im having some trouble printing it correctly on the screen.

    echo $before_widget;
    		echo '
    		<article class="news">
    			<header class="heading small">
    				<span class="icon icon-news">
    				</span>
    				<hgroup>
    					<h2>' . $title . '</h2>
    					<h4>' . $subtitle . '</h4>
    				</hgroup>
    			</header>';
    
    			$recent = new WP_Query("cat=". $cat ."&showposts=". $posts .""); while($recent->have_posts()) : $recent->the_post();
    
    			echo '
    			<div class="news-item">
    				<a href="'.the_permalink().'" class="heavy">'.the_title().'</a>
    				<p class="news-excerpt">
    					'.the_excerpt().'
    					<span class="read-more"><a href="'.the_permalink().'">L?s mer...</a></span>
    				</p>
    			</div>';
    
    			endwhile;
    
    		echo '
    		</article>
    		';
    
    		echo $after_widget;

    As you probably see im no phpcoder ?? Right now the output is: All the functions for permalinks, title and all that gets executed first, then my “layout” is beneeth it, empty. What am i doing wrong? Thank you very much in advance!

Viewing 1 replies (of 1 total)
  • Thread Starter mYrAn

    (@myran)

    Solved it myself!

    echo '
    <div class="news-item">
    <a href="';
    the_permalink();
    echo '" class="heavy">';
    the_title();
    echo '</a><p class="news-excerpt">';
    the_excerpt();
    echo '<span class="read-more"><a href="';
    the_permalink();
    echo '">L?s mer...</a></span></p></div>';
Viewing 1 replies (of 1 total)
  • The topic ‘Widget – running a WP_Query in it?’ is closed to new replies.