How to reverse the order of WordPress blog posts?

Maybe page.php is not your friend for this one. It depends where is the list of posts you want to modify. Try index.php for homepage or archive.php for category based views. Check http://codex.wordpress.org/Theme_Development#Template_Files_List page.php is used when an individual Page is queried – that means this page is usually the only post displayed there. Playing … Read more

How to insert content from another Custom Post type into Post?

Currently the best way I know to handle that is the Posts 2 Posts plugin: http://wordpress.org/extend/plugins/posts-to-posts/ Here’s an example showing how to set up the custom post types (if you already have them it’s more for other’s benefit who might be reading this) as well as the function call to p2p_register_connection_type() needed by the plugin … Read more

Setting posts per page in query_posts

Here’s what I usually use the pre_get_posts action to change a single query value for a taxonomy or category page: /** * Control the number of search results */ function custom_posts_per_page( $query ) { if ( $query->is_tax(‘mytaxonomy’) || $query->is_category(‘mycategory’) ) { set_query_var(‘posts_per_page’, 9); } } add_action( ‘pre_get_posts’, ‘custom_posts_per_page’ );

Static Front-Page Excerpts

Is there any particular reason not to use the front-page.php template file, and just not bother with trying to pull WordPress headers into external files? Using the front-page.php template file is easy: Create a new static Page, with any arbitrary name (let’s call it “Front Page”) Go to Dashboard -> Settings -> Reading and set … Read more

how can i use custom field in query post

Your meta_query needs to be a nested array, like so; $args = array( ‘posts_per_page’ => ‘5’, ‘cat’ => ‘3’, ‘orderby’ => ‘rand’, ‘meta_query’ => array( array( ‘key’ => ‘Featured List’, ‘value’ => ‘Yes’ ) ) ); And I get the feeling you don’t actually need a LIKE match – this’ll perform a loose comparison, and … Read more

how can i get posts from custom post type particular taxonomy category

If you read http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters in detail it outlines everything you need. Take a look at the following code sample taken from the codex. It should help you 🙂 $args = array( ‘post_type’ => ‘Article’, /* This is where you should put your Post Type */ ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, … Read more

Order posts using a custom array

You would need to build your own query and pass it to query_posts i.e. if your array of post ids is: array (10,21,1) // corresponding to post ids. then you can query this way: select * from wp_posts where `ID` in (10, 21, 2) order by field(ID,10,21,2) This will give you a result set in … Read more

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