Dynamically name array in WordPress loop – add/get values

From the PHP manual: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ‘[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*’ Hence before diving into your code further: It would need much … Read more

Why isn’t my Meta_Query running?

If you haven’t assigned it to any hook and you don’t call it, then it can’t work – this function is never called. You should assign it to pre_get_posts hook, I guess (at least it looks so). Add this after your function: add_filter( ‘pre_get_posts’, ‘ah_meta_queries’ ); It should work fine then.

Custom Taxonomy + JQuery Tabs

This should work, but it’s not tested <div id=”tabs”> <ul id=”tab-menu”> <?php $terms = get_terms(‘category’); global $wpdb; $posts = array(); if ( is_array($terms) && ! empty($terms) ) { $active = null; foreach ( $terms as $i => $term ) { $ids = $wpdb->get_col( $wpdb->prepare(“SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d”, $term->term_taxonomy_id )); $articles_count = … Read more

pre_get_posts redirecting

you can allow only registered user to see your content by 1.this solution for post show only to login user class RavsPublic { function __construct() { add_action(‘pre_get_posts’, array($this, ‘try_redirect’)); } function try_redirect( $query ) { // not on home page and not login if( !is_home() && !is_user_logged_in() ){ // send them to home page wp_redirect( … Read more