Articles of wp query

Is it possible to create a shortcode that will query a post based on taxonomies?

I am working on a site that will be listing a few hundred products and we wanted to be able to quickly/easily show specific products on a page based on taxonomies. I have been doing some research and thought I was on the right track. First, I found this article on which I thought […]

How to find if a post with custom_field == X exists?

I need to find if a post with a custom field X equal to Y exists in a wordpress installation. Should I do it with a simple sql query or is there something build in that can help me achieve it?

is_search was called incorrectly

I created a search form which searching by category filter and keyword input. The search form code is here- <form action=”<?php bloginfo(‘url’); ?>” method=”get” role=”search” class=”dropdown-form”> <div class=”input-group”> <span class=”input-group-addon”> <?php wp_dropdown_categories(array( ‘show_option_all’ => ‘all categories’, ‘class’ => ‘search_cats’ )); ?> </span> <input type=”search” class=”form-control” placeholder=”<?php esc_html_e(‘Search anything…’, ‘onepro’); ?>” name=”s”> <span class=”input-group-addon”> <button type=”submit”><i […]

Post thumbnail alt title

I wanted to know if alt text is required like title for post thumbnails and how can add it in my related post query? I’m using this code to get the post thumbnail: EDIT: Solved <div class=”td-module-thumb”> <a href=”<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <?php if (has_post_thumbnail()) { the_post_thumbnail(‘td_324x235’, array(‘alt’ => get_the_title())); } else { […]

Handling form request from plugin file

In a plugin I have a payment form that needs to be submitted (via the action= attribute) to a .php file, also located in my plugin directly. After some research, it seems like the “wordpress way” to call up individual plugin files is to actually use custom queries on index.php instead. I’ve done so with […]

Filtering by Post Meta Custom Fields – Performance

I could use some advise on how to structure my data for performance. I have a custom post type with a lot of custom meta data stored in the wp_postmeta table as a serialized array under one meta key for each post. Now, I need to get some posts from that post type, and filter […]

Custom Post Types not showing, custom WP_Query

My posts where showing for a while but now they are gone from my page. I see no mistakes and there’s no error messages in debug mode, I really don’t know why wouldn’t my posts show with this code, specially when it was working before. All I did was add the Advanced Custom Fields plugin, […]

WP_Query order by multiple meta keys & fields

How to order query by multiple meta keys and fields/custom fields? This is my code: $args = array ( ‘post_type’ => ‘listing’, ‘posts_per_page’ => -1, ‘tax_query’ => array ( array ( ‘taxonomy’ => ‘listing_category’, ‘field’ => ‘slug’, ‘terms’ => urldecode($category) ), array ( ‘taxonomy’ => ‘location’, ‘field’ => ‘slug’, ‘terms’ => urldecode($location) ) ), //*** […]

what is diference wp_get_attachment_url / wp_get_attachment_src / get_post_thumbnail_id?

**this is code exemple I need a gallery of images, small photos down, clicking shows an image above. So far I can not open large image. ** <li><a data-image-id=”‘.$photo_id.'” href=”‘. get_permalink($photo_id).'”> <img data-image-id=”‘.$photo_id.'” class=”thumbnail” src=”‘.get_the_post_thumbnail(‘small_thumbnail’).'”></a></li>

Passing JSON data from WP Query into AJAX causing NULL errors

I am currently using a WP_Query that’ll trigger from an AJAX call when a button is pressed. The post meta fields lat lng will be used as location data for a google map. The query outputs fine without AJAX but cannot seem to get it to return the results with it. The response I receive […]