Load more AJAX on WP Query

if you want to use ajax in wordpress you must have to follow these step: 1) first make your js file like main.js. 2) localize it in functions.php with wp_localize_script(). wp_enqueue_script( ‘main.js’, get_template_directory_uri().’/js/main.js’, array( ‘jquery’ ) ); wp_localize_script( ‘main.js’, ‘ajax_object’, array(‘ajax_url’ => admin_url(‘admin-ajax.php’)) ); 3) make your javascript or jquery code to run your query … Read more

Identify which loop you are hooking into; primary or secondary?

Just a quick update that a new method is_main_query() has been introduced in WP 3.3. Example: add_action( ‘pre_get_posts’, ‘foo_modify_query_exclude_category’ ); function foo_modify_query_exclude_category( $query ) { if ( $query->is_main_query() && ! $query->get( ‘cat’ ) ) $query->set( ‘cat’, ‘-5’ ); } Resources: WPDevel: New API in 3.3: is_main_query() Codex reference: is_main_query() Related Trac Ticket #18677

get images attached to post

It’s better to use get_children than get_posts. Here is a quick example that will work. This is in the form of a function that is defined in your plugin or in functions.php then use the function as a template tag. /** * Gets all images attached to a post * @return string */ function wpse_get_images() … Read more

WP_Query orderby taxonomy term value (numeric)

No, there is no way to do this with default WP Core. @heathenJesus talks about meta data not taxonomies. See http://scribu.net/wordpress/sortable-taxonomy-columns.html for a proper solution. And a more thorough explanation of why this is not something built into Core: Using wp_query is it possible to orderby taxonomy?

WP_Query using meta_query with relation OR and orderby meta_value doesn’t work

The issue is that WordPress are getting all posts that has a ‘startDate’ meta key, no matter the meta value. You can understand that form this part of the request: … AND ( wp_postmeta.meta_key = ‘startDate’ OR ( mt1.meta_key = ‘startDate’ AND CAST(mt1.meta_value AS CHAR) >= ‘20140305’ ) OR ( mt2.meta_key = ‘endDate’ AND CAST(mt2.meta_value … Read more

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