Get page->parent’s name?
Once you’ve got the id of a post or page, use get_the_title($id) to get the page title (which is what I assume you mean by name) Codex Reference
Once you’ve got the id of a post or page, use get_the_title($id) to get the page title (which is what I assume you mean by name) Codex Reference
Your meta field contains the ID of the attachment, you need to fetch that ID, then get the filename using that attachment ID. $doc_id = get_post_meta( get_the_ID(), ‘pdf’, true ); $filename = basename( get_attached_file( $doc_id ) ); echo $filename;
The reason you have a problem is 0 is also considered equal to false, when the get_post_meta call returns false, it’s also the same as being equal to 0. if( !get_post_meta( $post_id, ‘some-non-existant-field’, true ) == 0 ) Would be the same as … if( get_post_meta( $post_id, ‘some-existing-field’, true ) == 0 ) ..the only … Read more
The query value parameters can be set to true ( returns single result) or false ( an array). http://codex.wordpress.org/Function_Reference/get_post_meta For instance http://www.mattvarone.com/wordpress/query-multiple-meta-values/
You can use get_the_author_meta function. You can learn more about it here: https://developer.wordpress.org/reference/functions/get_the_author_meta/ Usage in your case: <a href=”https://wordpress.stackexchange.com/questions/290522/mailto:<?php echo get_the_author_meta(“user_email’);?>?subject=<?php the_title(); ?>”>Apply</a>
A very basic solution would be to use the Transients API, an example… function setPostViews($postID) { $user_ip = $_SERVER[‘REMOTE_ADDR’]; //retrieve the current IP address of the visitor $key = $user_ip . ‘x’ . $postID; //combine post ID & IP to form unique key $value = array($user_ip, $postID); // store post ID & IP as separate … Read more
i ended up building a plugin that enforces radio buttons for any taxonomy. http://wordpress.org/extend/plugins/radio-buttons-for-taxonomies/ for the project in question i will probably also save the taxonomy as meta. sucks that i need/want half the ability of taxonomy (knowing other available terms, etc), but need the sorting by meta.
I’ve used this to insert posts with ACF/postmeta data successfully, but please test it on a development site before deploying live, there might be some terrible assumptions. Generally, it assumes that you only have each name once, that is “myfield” doesn’t exist in two field groups with different meanings. $mycustomvalue = 123; $f_mycustomfield = get_acf_key_by_name(“mycustomfield”); … Read more
Is it possible to update a post meta field through REST API if the format of it when registered is nested?
You should use register_meta to add the meta field to the rest controller. Here the example from the link to expose the field my_meta of the custom post type my_article: register_meta(‘post’, ‘my_meta’, [ ‘object_subtype’ => ‘my_article’, ‘show_in_rest’ => true ]);