Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

New answers tagged

0 votes
Accepted

Is there a way to make [Table Of Content] plugin while not using revision data?

The only reason it's talking about revisions is so the TOC still displays when you preview a post. It's nothing to do with your problem, which is that the TOC plugins are looking at your post content, ...
user avatar
  • 51.8k
0 votes

List all images from a single post meta value

Get images from Gallery Custom Post Meta <?php $meta = get_post_meta(get_the_ID(), 'gallery'); foreach ($meta as $m) : $img_atts = wp_get_attachment_image_src( $m, $default ); $...
user avatar
1 vote
Accepted

list/consult Taxonomy only for the respective author/creator in dashbboard

The WP_Term_Query class doesn't have a method named set, and calling $query->set() in my case resulted in a fatal/critical error saying "Call to undefined method WP_Term_Query::set()". :/ ...
user avatar
  • 31.5k
0 votes

Order by the first array within a meta_query

Thanks for the input! That's how I built my code now. But the "posts_per_page" can't be controlled by the arrays now. It will always output all posts. add_shortcode( 'display_events', '...
user avatar
0 votes
Accepted

Is there a way to nest taxonomies or custom fields deeper than one level below the post type?

WordPress content is implemented in two foundational structures: Posts represent distinct "instances" of content, and Taxonomy Terms aggregate and organize Posts according to their shared ...
user avatar
  • 5,195
0 votes
Accepted

comments_where Hook

Yes, a quick search of developer.wordpress.org reveals comment_feed_where. Note that this won't work with get_posts unless suppress filters is turned off, and that what you're trying to do is going to ...
user avatar
  • 51.8k
0 votes

Order by the first array within a meta_query

You can use get_posts() for both event types and merge them. $merged_events = array(); $upcoming = get_posts(array( /* Your upcoming events args here. */ )); $past = get_posts(array( /* Your ...
user avatar
  • 2,630
0 votes
Accepted

Table of contents (TOC) plugin is not showing header tag

Even if they're not looking at revisions, all table of contents plugins are likely to only look at post_content rather than postmeta, because postmeta can be anything and it would be hard to query for ...
user avatar
  • 8,643
0 votes

query_posts and only show results if a custom field is not empty

The accepted answer was not working for me with a text field in Advanced Custom Fields. It kept pulling all posts once they were saved after the text field was added to the Custom Fields. I had to ...
user avatar
  • 426
2 votes
Accepted

How get custom field from custom taxonomy?

Since you are using ACF, you can take advantage of the get_field() function ACF provides. You will need to pass the term object as the second parameter. $image = get_field( 'field_key', $custom_term );...
user avatar
  • 2,630
2 votes

How get custom field from custom taxonomy?

The thumbnail is probably stored in the termmeta table using a meta key specified the jetengine plugin, which is out of scope here. You should be able to identify the key by querying the DB for one of ...
user avatar
1 vote
Accepted

How to inherit field value from parent post into in child / sub post

You can use get_post_field( 'post_parent' ) to get the parent ID of the current post. Whilst ACF is technically off-topic, FWIW you can pass the ID of a post as the second parameter to get_field. ...
user avatar
  • 34.9k
0 votes

Rewrite comment form post ID on submit

This bit of code will update the comment_post_ID with the value submitted using your custom form. function wpse405448_update_comment( $comment_ID, $comment_approved, $commentdata ) { if ( isset($...
user avatar
  • 2,630
1 vote
Accepted

how to get serialized post meta

get_post_meta() with the 3rd parameter set to true will return a single item with the key specified in the 2nd parameter (_custom_field in your code). If this item is an array, it'll return as the ...
user avatar
  • 10.3k
1 vote
Accepted

Hide Heading if ACF Field is empty

Move the outer(of the two) div.local_faq inside the if statement which checks if the faq field is set, because that’s the outer parent container. Also it would make sense to change the outer container ...
user avatar
  • 2,315
3 votes
Accepted

Custom Fields - How to create a list from multi-line entries of a single value

Yes, grab the value via get_post_meta, then it's just a matter of generic PHP loops and string manipulation. Try using the explode function with \n as the separator to create an array you can loop ...
user avatar
  • 51.8k
0 votes

check for duplicate user meta data before updating

Can't we do something like this, I just printed the result of above query, it is returning lot of repeated Ids: $res = $wpdb->get_row("SELECT 1 FROM $wpdb->usermeta WHERE $wpdb->...
user avatar
  • 1

Top 50 recent answers are included