How do I display the next 3 posts in the sidebar?

$args = array( ‘numberposts’ => 3, ‘offset’ => 5 ); $posts = get_posts( $args ); foreach( $posts as $post ){ setup_postdata( $post ); [output the post here with the_title(), the_content(), etc] } If you search in the codex with ‘query posts’, you will find a lot.

Query Custom Post Type and sort by year

You don’t need to create a page template to list the project post type, just go to /project/ and you’ll have a full date ordered listing. The template powering that page will be determined as follows: archive-project.php archive.php index.php So create an archive-project.php in your theme. Using this you can specify to list only the … Read more

How can i display in themplate file only a few post

Ok. You are toggling your display according to a $_GET parameter that you have added to the URL– this switch in your archive.php $view = ‘poster’; $mode = stripslashes( $_GET[“afisare”] ); $modes = array(‘complex’, ‘simple’, ‘poster’); if(in_array($mode, $modes)) $view = $mode; get_template_part(‘persoane’, $view); You can alter how many posts will display but that is much … Read more

Stop header code from showing in category page?

You can achieve that by changing the conditional to if ( !is_home() && !is_archive() ) Also consider using if and else if. So your optimized code would be: <?php if ( !is_home() && !is_archive() ) { if ( get_post_type() == ‘pretty-little-liars’ ) { echo ‘<div id=”headerimg”><img src=”http://tv-cafe.com/wp-content/uploads/2013/01/pllbanner.png”></div>’; } else if ( get_post_type() == ‘revenge’ ) … Read more

How to make a list of posts displaying them 5 by 5 with a “next posts” link?

I found the actual answer in a stackoverflow question. Quoted from the answer: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => $paged ); $wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; ?> <!– then the pagination … Read more

Create /archive page in WordPress Theme

What I’m trying to do is make a separate page on the site that lists all posts (not sorted by tag/category/year) in a single, easily-accessible portion of the site by just going to /archive (e.g. www.example.com/archive) The correct approach is, indeed, to create a custom page template, so that the user can create a static … Read more

Apply custom taxonomy archive template to children

As you can see in this image, template hierarchy limits to taxonomy-$taxonomy-$term.php. I don’t know why a subterm falls back to taxonomy-$taxonomy.php, but I guess it searches for a taxonomy-$taxonomy-$term.php in wich $term would be workshops, science labs and so on. And since those don’t exist (I suppose), it falls back on taxonomy-$taxonomy.php. You could … Read more

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