Page template with different page and post content

the_content() (and many others) must be inside The Loop. For retrieving a post/page/custom-post-type data outside the Loop, take a look here: Get post content from outside the loop The working code, based on your example, would be: <div class=”middle-inner”> <div class=”center-inner”> <!– This is content –> <?php global $post; query_posts(“post_type=roomtype&orderby=name”); if ( have_posts() ) { … Read more

Display random post on a page with post permalink in URL

What you are asking is how to redirect the visitor to a random post. Here you go: <?php /* * Template Name: Random Redirect */ query_posts( array( ‘showposts’ => 1, ‘orderby’ => ‘rand’, ) ); if (have_posts()) : while (have_posts()) : the_post(); header( ‘Location: ‘ . get_the_permalink() , false , 303 ); The syntax is … Read more

Custom MySQL Query with logic

Thank’s everyone for your attention. If anybody will need to query database with two postmeta, here is the code SELECT p.* , CASE WHEN m1.meta_value=0 OR m1.meta_value IS NULL THEN m2.meta_value ELSE m1.meta_value END meta_value FROM aka_v_posts p LEFT JOIN aka_v_postmeta m1 ON p.id=m1.post_id AND m1.meta_key=’_wpsc_special_price’ LEFT JOIN aka_v_postmeta m2 ON p.id=m2.post_id AND m2.meta_key=’_wpsc_price’ WHERE … Read more

How to query post like normal search would do. within search.php page

This is what i did: I run another query without pagination like this: $newQuaryVars=”&posts_per_page=99999999999999&post_type=post”; $posts = query_posts($query_string .$newQuaryVars); $categoriesList = array(); $categoriesAmounts = array(); Then in the while have posts i did the following: while ( have_posts() ) : the_post(); $postCategories = get_the_category(); if($postCategories){ foreach($postCategories as $categoryInfo) { $categoriesAmounts[$categoryInfo->term_id][‘amount’]++; $categoriesList[$categoryInfo->term_id] = array( ‘name’ => $categoryInfo->name, … Read more

Error sending array of inputs

As I said in a comment above, setting query_var => false for the custom taxonomy is not a solution because this will make term pages in frontend return a 404 error. Renounce to term pages in the frontend to make a simple form to work is far away to be a solution. Finally I’ve solved … Read more

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