Dynamically create array from page title
I think this is what you’re looking for: $$arr_name = array(); If $arr_name = ‘post_title’, then the above would mean: $post_title = array();
I think this is what you’re looking for: $$arr_name = array(); If $arr_name = ‘post_title’, then the above would mean: $post_title = array();
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
It looks like the problem is here: ‘terms’ => $term where in your case it’s like: ‘terms’ => “array( ‘peoria’, ‘adams’ )” but it should be like ‘terms’ => array( ‘peoria’, ‘adams’ ) By looking at your code snippet, you could try ‘terms’ => explode( ‘,’, $term ); since explode will return the array you … Read more
Try this after your $wpdb query: // collect calendar id’s $ids = array(); foreach( $calendar_entries as $calendar_entries): array_push( $ids, $calendar_entries->id ); endforeach; // query the above calendar id’s $args = array( ‘post_type’ => ‘post’, ‘post__in’ => $ids, ‘orderby’ => ‘id’, ‘order’ => ‘DESC’ ); $query = new WP_Query( $args ); You can also modify the … Read more
Try it like this: if ( $query->have_posts() ) { $categories = $category_ids = array(); while ( $query->have_posts() ) { $query->the_post(); foreach ( ( get_the_category() ) as $category ) { if ( ! in_array( $category->term_id, $category_ids ) ) { $category_ids[] = $category->term_id; $categories[] = $category; } } }; } get_the_category() returns an array of objects. I … Read more
update_post_meta array issues
Using array page name together with page id to deregister script
It looks like get_user_meta() returns an array like such. array(2) { [0]=> array(1) { [0]=> } [1]=> array(1) { [0]=> } } Then when update_user_meta() stores the array it sticks it inside another array like this. Edit: As it turns out get_user_meta() is encapsulating the result in an array when it grabs it. array(1) { … Read more
Use the orderby and order parameters in the argument list. See the Orderby_Parameters section of WP_Query for details. $category_ids = $arr_records = $post_data = array(); $categories = get_categories( ‘child_of=4’ ); foreach( $categories as $category ) { $category_ids[] = $category->term_id; } $post_data = get_posts( array( ‘cat’ => $category_ids, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ) ); … Read more
Echo the key from a select-box in Array with get_option (Settings API)