How to Make infinite loop of post

A very basic example, $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 ); $query= new WP_Query($args); while ( $query->have_posts() ) : $query->the_post(); the_content(); //example, use whatever template functions you like… endwhile; wp_reset_postdata(); //reset Post Data wp_reset_query(); //destroy query incase of using multiple queries on same page Important: Note, that this is probably an inefficient … Read more

Can’t understand why sometimes a [caption] field appears

The part shows up because one of your authors/editors added a caption to the image when it was inserted into the post. You will have this problem not only with captions but with any other shortcodes that your authors/editors use. And you should be aware that WordPress includes several in its Core but various plugins … Read more

Blog post not showing title

This happens because you have set the post format of that entry to link, and for that post format TwentyEleven does not show the post title: .format-link .entry-title { display: none; } Solution: Use another post format (standard for example) or another theme.

get posts from Custom Post Type & Category

It is ‘cat’, not ‘category’. query_posts( array( ‘numberposts’ => 5, ‘cat’ => 9, ‘post_type’ => ‘blog’ ) ); Also, be aware the query_posts alters the main page query. Unless you specifically intend to do that, and need to do it, use get_posts or make a new WP_Query object. And if you do have to use … Read more

Using setup_postdata() with multi-dimensional array

There was a similar (related) question on here recently. The upshot is that get_the_title() uses the global $post when no argument is passed. And setup_postdata() doesn’t set that global (a mistake I’ve made before now ). In your case, I would do the following: foreach( $locations as $post ) { setup_postdata(get_post($post[‘id’])); echo get_the_title($post[‘id’]); } wp_reset_postdata(); … Read more

Form to post new post with custom taxonomies

Update your form to include the term-id, instead of just <input type=”checkbox” /> use <input type=”checkbox” name=”taxonomy_id[]” value=”‘. $industryterm->term_id .'” />. That way you are actually sending along some values, in this case the term id. And in the args for wp_insert_post() make sure to include something like this: ‘tax_input’ => array( ‘industries’ => $_REQUEST[‘taxonomy_id’] … Read more

How to disable the_excerpt from one post

First of all, WordPress already includes a function for displaying excerpts: the_excerpt() Secondly, your second piece of code isn’t actually displaying anything. You need to use the echo statement for displaying text on the page. However, WordPress provides functions that actually display the content and excerpt on the page: the_content() and the_excerpt(), respectively. if( in_array( … Read more

How to create a second posts page which client can update

This is a perfect case for custom post types Simply create a post type called “specials” and you can use it just like your regular posts. EDIT: If you’re new to WordPress and aren’t interested in editing PHP, you can use a plugin like the Custom Post Type UI