recent posts for different categories

If the blog / portfolio items are grouped into categories, you can do this at the top of your template file: <?php $portfolio_query = new WP_Query(‘posts_per_page=3&category_name=portfolio’); // note ‘portfolio’ is the category slug $blog_query = new WP_Query(‘posts_per_page=3&category_name=blog’); // note ‘blog’ is the category slug ?> Then in your markup: <?php if ($portfolio_query->have_posts()) : ?> <div … Read more

Recent posts with featured image or fallback image with permalink

Here’s the relevant part of your code that should work: // This will make a URL like http://yoursite.com/path/to/fallback.png $fallback_image = site_url( ‘/path/to/fallback.png’ ); $fallback_image = “<img src=”https://wordpress.stackexchange.com/questions/224740/{$fallback_image}” />”; foreach( $recent_posts as $recent ){ echo ‘<div class=”sidebar-entries”>’; $featured_image = get_the_post_thumbnail( $recent[‘ID’], ‘sidebar-thumb’, array( ‘class’ => ‘sidebar-image’ ) ); if ( ! strlen( $featured_image ) ) { … Read more

How to truncate titles in Recent Posts widget?

I wasn’t sure if i would answer or simply vote to close this topic, i feel i sufficiently asnwered the original topic you’re referring to, i’d only be repeating myself here. That said, here’s an upto date version you can use(only took me 2 mins), you only need implement your own code to truncate the … Read more

the_excerpt not showing posts

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/60224/<?php the_permalink(); ?>”><?php the_title(); ?></a> <?php the_excerpt() ?> <?php endwhile; else: ?> <p>Nothing to see here.</p> <?php endif; ?> This is the right syntax to show title and the excerpt on home page.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)