Forum Replies Created
-
AuthorPosts
-
Andrew Tegenkamp
ParticipantAh, thanks. Our theme came with MetaBoxes and some extensions, but not all, so we've bought some like MB Blocks but not Admin Columns. I went to look at the cost of that and the sales page at https://metabox.io/plugins/mb-admin-columns/ mentioned a standalone plugin that does Admin Taxonomy Filter, which is all we need for now, so that plugin solved it.
I appreciate your support and willingness to recommend a free plugin when that fits the solution!
Andrew Tegenkamp
ParticipantMeant to add my current solution is to get the array with rwmb_get_value and loop it with WP's built in wp_oembed_get, so please update this if there is a better way:
$url = rwmb_get_value( 'view_kids_oembed' ); printPre($url); foreach ($url as $link) { $embed = wp_oembed_get($link); if ($embed) { echo $embed; } else { echo '<a href="">'.$link.'</a><br>'; } }Andrew Tegenkamp
ParticipantThanks, that worked great!
Andrew Tegenkamp
ParticipantHi,
I'm sorry for not following up on this as I believe I found the answer in the default WP docs.
To clarify, I was hoping to show the Gutenberg block I created differently on different post/page templates. I am able to read the page template using code below, and added an if statement based on the result.
If you or anyone else has other or better suggestions, I'm definitely open to other ideas, too.
function metabox_render_callback($attributes) { //echo get_the_ID().'='.get_page_template_slug(get_the_ID()); //current postID and template //if statement based on get_page_template_slug result }Thanks for following up, and I believe this is solved 🙂
Andrew Tegenkamp
ParticipantThanks, they pointed me to https://awhitepixel.com/custom-url-endpoints-wordpress-rewrite-api/ for this specific request in case anyone else comes here looking in the future.
Andrew Tegenkamp
ParticipantWell, this was my silly mistake as I put the post_types inside the fields array. I moved it out and it worked perfectly. Feel free to delete this question or mark it as solved with the corrected code below! On to tabs...
add_filter('rwmb_meta_boxes', 'career_data'); function career_data($meta_boxes) { $meta_boxes[] = [ 'title' => 'Career Data', 'fields' => [ [ 'id' => 'career_data', 'name' => 'Wages', 'type' => 'wysiwyg', //'visible' => [ 'post_type', 'career' ], ], ], 'post_types' => ['career'], ]; return $meta_boxes; }Andrew Tegenkamp
ParticipantThanks. I wasn't sure, but was able to create a custom field type using https://docs.metabox.io/creating-new-field-types/ as that met my needs better.
Andrew Tegenkamp
ParticipantThanks. I see it does work when I add query_args and post_status of inherit since Media files use Inherit instead of Publish by default. This seems to get me what I want as it looks like the WP_Query loop knows to only get the most recent Post/Page and not all the inherited revisions.
'fields' => [ [ 'id' => 'vpp_post', 'type' => 'post', 'name' => 'Post or Page?', 'post_type' => ['post','page','attachment'], 'field_type' => 'select_advanced', 'query_args' => [ 'post_status' => ['publish','inherit'], 'posts_per_page' => - 1, ], ], ],I'm not sure if updating the code to work without the query_args is the right answer, or updating the docs, but I'll let you and the devs work that out 🙂
Thanks again for taking a look!
Andrew -
AuthorPosts