Widget : html 2 dimensional array doesn’t work

Ok, with a quick dirty hack I have achieve my goal : Instead of myCollection[id][myField] I give to the get_field_name‘s function something like this : collection][id][field. So the generated code became : name=”widget-pricetable-ibsciss-widget[2][box][1]Widget : html 2 dimensional array doesn’t work” And my array just look perfect now : array(3) { [“title”]=> string(12) “Global title” [“box”]=> … Read more

return paginate_comments_links() as array

The first thing to say would be, you can’t say you haven’t been warned – see codex page paginate_comments_links(), section »Defaults«: These arguments are mostly to make the call of paginate_links() work, so be careful if you change them. It’s true, paginate_comments_links() is pretty much just a already customized version for comments of paginate_links(), with … Read more

Removing a taxonomy term

Your issue is last argument in wp_set_object_terms() call. You are setting $append to true, so it essentially checks if input is already present and does nothing else. You want it set to false (which is also default) so that terms are forced to be same as input and difference (what you removed) is deleted from … Read more

How to get specific string in explode array?

I see two problems here. One is that the explode() doesn’t actually specify the correct split string, which is ‘, ‘, WITH a space. What is written in the sample: ‘post_type’ => explode( ‘,’, $posttype ), What is written in the example shortcode: [myquery posttype=”cpt_press, cpt_two, cpt_three, cpt_etc”] Note that there is a comma AND … Read more

Category based on post id

WP_Query itself can’t do that logic internally but you can easily create the query dynamically. $args = array( ‘meta_key’ => ‘name’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘posts_per_page’ => ‘-1’ ); if ($post->ID == 1) { $args[‘category_name’] = ‘first’; } elseif ($post->ID == 2) { $args[‘category_name’] = ‘second’; } $custom_loop = new WP_Query($args);

display post tags on single.php inside loop

You’re getting Array because that’s exactly what wp_get_post_tags returns; an array (and when you try and echo one in PHP it’ll simply output Array). As @Chip Bennet suggested, use the_tags() instead, which outputs an HTML string.

I need to exclude from a query a category and a few custom taxonomies

Change ‘relation’ => ‘OR’ to ‘relation’ => ‘AND’ to apply both exclusions to all posts returned. It may seem counterintuitive, but a post that satisfies one of the exclusions will be included even if it doesn’t satisfy the other. EDIT From the code linked in your comment below, this is the query being generated: SELECT … Read more

ACF checkbox array is returning numbers, not labels [closed]

ACF is actually doing what it should – storing a numerical array of selected values. If you want the label you can levy get_field_object, which returns information about the custom field (rather than the value of it for the given post). $field_obj = get_field_object( ‘nav_widget_platforms’ ); $platforms = get_field( ‘nav_widget_platforms’ ); foreach ( $platforms as … Read more