new WP_Query issues

The issue with your query is that new WP_Query($query_string,$args); is not correct syntax, however, creating a new WP_Query is not the way to do what you want. See the codex page for pre_get_posts for the correct way to modify the main query. I assume by setting posts per page to 999, you want to show … Read more

Display Posts Query with IF function

If I understand you, you want to filter out faculty members who do not have any awards at the query stage. Replace your code: <?php query_posts( ‘post_type=mtt_page’); ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> with this (untested): <?php $args = array( ‘post_type’ => ‘mtt_page’, ‘posts_per_page’ => -1, ‘meta_query’ => … Read more

Posts of specific category on page and excluded from index.htm

1. CSS/HTML issues are off-topic for this site, per the FAQ. But, have you tried investigating with Firebug or Chrome’s dev tools? The answer is obvious in seconds. This page http://www.biz.uiowa.edu/bta/test/ has large headings because of .singular .entry-title { font-size: 2em; margin-bottom: 0.3em; } Since you are running a second loop on a singular page, … Read more

PHP dynamical conditional post display

Your code is disjointed, but from the look of it you are passing an ID as the category_name value. The switch that would convert that to a name comes after the query. Move this, or something like it,… $link=$_GET[‘link’]; if ($link == ‘1’){ $category_name=”accomodatins”; } if ($link == ‘2’){ cat_switcher(); } if ($link == ‘3’){ … Read more

How to break up php code to avoid echo

You have an extra “}”, there must be two such braces for two for each loops. Also you need to have endif; statement at end after endwhile. Parsing error may be due to extra “}”. Please try below code and let us know if it works. <?php $custom_terms = get_terms(‘videoscategory’); $other_custom_terms = get_terms(‘product_category’); foreach ($custom_terms … Read more

Different layout based on post amount?

for a standard query, you can check the amount of posts with: all posts for the query: $wp_query->found_posts and the posts on the page: $wp_query->post_count use that with a conditional statement to switch to the different layouts. example: <?php if ( have_posts() ) : //start of the loop// if ( $wp_query->found_posts <= 4 ) { … Read more

Restrict query_posts by Date?

I’ve done something in the past using custom fields. Maybe this can get you going in the right direction? This is done directly after the <?php while ( have_posts() ) : the_post(); ?> <?php $currentdate = date(“Ymd”); $expirationdate = genesis_get_custom_field(‘_racedate’); $expirestring = str_replace(“-“,””,$expirationdate); if (is_null($expirationdate)) { $expirestring = ‘30005050’; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP; … Read more

How can I change the publish date based on a custom field?

I don’t know how your front end form saves its data, but presumably it is using wp_insert_post and wp_update_post. If so, there is a filter called wp_insert_post_data that can be used to alter the post data before the post is inserted or updated. function reset_post_date_wpse_100021($data,$postarr) { var_dump($data,$postarr); die; //debug // your code return $data; } … Read more

Pagination linking to first page

Perhaps you can take a look at this question and the answers and check if you really want to use query_posts() as it is not recommended while dealing with posts pagination. Why not use pre_get_posts action instead? Or you can try something like this: <?php $custom_query = new WP_Query(array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘products’, … Read more

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