post var problem with shortcode loop

you really shouldn’t use query_posts() for anything other then the main query of the page. Instead you should use wp_query() or get_posts() , also since you return a value before running wp_reset_query() then its never actually being reset. so change your shortcode to this: function casestudy_shortcode($atts){ extract(shortcode_atts(array( ‘type’ => ‘case_studies’, ‘limit’ => ‘1’, ‘case’ => … Read more

Query add html after set amount of posts?

Here’s one way of doing it: <?php $courses = get_posts( array( ‘post_type’ => ‘courses’, ‘posts_per_page’ => -1 ) ); if ( $courses ) { print “\n” . ‘<div style=”background:pink”>’; foreach ( $courses as $course_count => $post ) { setup_postdata( $post ); the_title( “\n”, ‘<br>’ ); if ( 5 == $course_count ) { print “\n” . … Read more

Latest 5 post excerpts from 5 different authors in Sidebar

Think I’ve figured it out. Here’s the code I used courtesy of this thread on the WP Support Forum. Just replace ()<?php the_author_posts_link(); ?>() with whatever excerpt code you want to use. And Voila! <?php //list 5 latest authors $authors = array(); $count = 0; $args=array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, … Read more

Show posts from specific roles

Code you are after: <?php $wp_user_search = new WP_User_Query( array( ‘role’ => ‘administrator’ ) ); $admins = $wp_user_search->get_results(); $admin_ids = array(); foreach($admins as $admin) { $admin_ids[] = $admin->ID; } $args = implode(‘,’, $admin_ids); query_posts(“author=$args”); ?>

How to put posts in pages using query posts

get_posts may be easier for you to use: $args = array( ‘numberposts’ => 5, ‘category’ => ‘3’ ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <div <?php post_class(); ?> id=”post-<?php the_ID(); ?>” style=”padding-bottom:5px;”> <h2><a href=”https://wordpress.stackexchange.com/questions/22878/<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2> <div class=”post_meta”><?php twentyten_posted_on(); … Read more

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