Setting default category for display

I’m not sure you are understanding what a ‘category page’ is doing; for example your news page: http://papermepress.com/?cat=1 this is pulling out all post with the categoy ‘news’ which has cat id equal to 1. depending on your needs there are two possible things you can do. 1 – if you simply want all posts … Read more

Multiple item layout with one query

As @MridulAggarwal already stated, it’s a pretty basic PHP task that you’re confronted with: $wpse69584_posts = get_posts( array( /* Your Arguments */ ) ); echo $post[0][‘post_title’]; echo isset( $post[0]->post_excerpt ) ? apply_filters( ‘the_excerpt’, $post[0]->post_excerpt ) : apply_filters( ‘the_content’, $post[0]->post_content ) ; // etc. Or if you’re using a loop, it’s even easier: global $wpdb; if … Read more

Add default content to post (for specific category)

default_content runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you’d want the save_post hook, probably. You want to check the $_REQUEST global. add_filter( ‘default_content’, ‘my_editor_content’ ); function my_editor_content( $content ) { global $_REQUEST; if (isset($_REQUEST[‘post_category’]) && in_array($some_category_id,$_REQUEST[‘post_category’])) { $content = “My html … Read more

WP_Query breaks pagination

If you want to stay with a new Wp Query, as in your example, changing your $allsearch name for the query variable to $wp_query should do the trick. Looks like the pagination functions are expecting that variable name for the query… So, try that…

Displaying posts limit: can’t get pagination to display [duplicate]

Try reviewing this page on the codex. Using your above template, I would suggest the following: <?php if ( is_user_logged_in() ) : $args = array( ‘posts_per_page’ => ‘5’, ‘author’ => get_current_user_id(), // Removes a few lines of code 😉 ); $author_posts = new WP_Query( $args ); ?> <?php /* Author has posts? */ ?> <?php … Read more

How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?

try this $second_query = new WP_Query( $args ); if ( $second_query->have_posts() ): while( $second_query->have_posts() ) : $second_query->the_post(); $attachment_id = get_field(‘image’); $size = “customfeatins”; // (thumbnail, medium, large, full or custom size) $my_image = wp_get_attachment_image_src( $attachment_id, $size ); if (!my_image !== ”){ $image = $my_image[0]; } else { $image=”http://domain/image_source/your_image.jpg”; } endif; echo ‘<article> <img src=”‘ . … Read more

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