-
Author
Tagged: custom post types, get_cfield
-
February 26, 2015 at 17:22 #47792revonorwayParticipant
Hello, I’m trying to use the following code on custom post type, but nothing is showing up. I added the metaboxes, and have pasted a youtube video link in the oembed field, but still nothing… Any ideas why? Thx!
COPY CODE<div class="article-media"> <?php //oEmbed video $video = get_cfield('embed'); // video bg self hosted $bg_video_args = array(); $k_video = ''; if ( get_cfield('video_mp4') ) { $bg_video_args['mp4'] = get_cfield('video_mp4'); } if ( get_cfield('video_ogv') ) { $bg_video_args['ogv'] = get_cfield('video_ogv'); } if ( get_cfield('video_webm') ) { $bg_video_args['webm'] = get_cfield('video_webm'); } if ( !empty($bg_video_args) ) { $attr_strings = array( 'preload="0"' ); if (get_cfield( 'video_poster' ) ) { $attr_strings[] = 'poster="' . get_cfield( 'video_poster' ) . '"'; } $k_video .= '<div class="kleo-video-wrap"><video ' . join( ' ', $attr_strings ) . ' controls="controls" class="kleo-video" style="height: 100%; width: 100%;">'; $source = '<source type="%s" src="%s" />'; foreach ( $bg_video_args as $video_type => $video_src ) { $video_type = wp_check_filetype( $video_src, wp_get_mime_types() ); $k_video .= sprintf( $source, $video_type['type'], esc_url( $video_src ) ); } $k_video .= '</video></div>'; echo $k_video; } // oEmbed elseif (!empty($video)) { global $wp_embed; echo apply_filters('kleo_oembed_video', $video); } ?> </div><!--end article-media-->
February 26, 2015 at 17:42 #47796sharmstrModeratorDid you add your own meta boxes or the kleo one? If you’re using the Kleo meta boxes, the field is _kleo_embed, not embed.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 26, 2015 at 18:07 #47805revonorwayParticipantHello, yes I am using the kleo metaboxes, but this code is just a copy paste from what is used on kleo video post format.
I use it in a custom post loop and the videos show up on posts, but not other custom post types.
Are you saying I should use
get_cfield('_kleo_embed');
In this way?
February 26, 2015 at 18:51 #47818sharmstrModeratorattach your entire file.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 26, 2015 at 20:43 #47849revonorwayParticipantHere is the file I have the loop in and the attached templates. For the posts everything works fine, but for the video custom post types, the video does not appear…
February 26, 2015 at 20:45 #47850revonorwayParticipantHere is my entry.php
COPY CODE<?php /** * BuddyPress - Activity Stream (Single Item) * * This template is used by activity-loop.php and AJAX functions to show * each activity. * * @package BuddyPress * @subpackage bp-legacy */ ?> <?php do_action( 'bp_before_activity_entry' ); ?> <li class="<?php bp_activity_css_class(); ?>" id="activity-<?php bp_activity_id(); ?>"> <div class="activity-avatar rounded"> <a href="<?php bp_activity_user_link(); ?>"> <?php bp_activity_avatar(); ?> </a> </div> <div class="activity-content"> <div class="activity-header"> <?php bp_activity_action(); ?> </div> <?php if ( bp_activity_has_content() ) : ?> <div class="activity-inner"> <?php $blogpost_id = bp_get_activity_secondary_item_id(); if ($blogpost_id) : // Prepare loop $args = array('p'=>$blogpost_id, 'limit'=> '1'); $loop = new WP_Query($args); // Start loop for entry cards posts $loop->the_post(); ?> <?php if ( 'post' == get_post_type($blogpost_id) ) { include('templates/activity-post-entry.php'); } ?> <?php if ( 'videos' == get_post_type($blogpost_id) ) { include('templates/activity-video-entry.php'); } ?> <h2><?php echo get_the_title($blogpost_id); ?></h2> <?php endif; ?> <?php bp_activity_content_body(); ?> </div> <?php endif; ?> <?php do_action( 'bp_activity_entry_content' ); ?> <div class="activity-meta"> <?php if ( bp_get_activity_type() == 'activity_comment' ) : ?> <a href="<?php bp_activity_thread_permalink(); ?>" class="button view bp-secondary-action" title="<?php _e( 'View Conversation', 'buddypress' ); ?>"><?php _e( 'View Conversation', 'buddypress' ); ?></a> <?php endif; ?> <?php if ( is_user_logged_in() ) : ?> <?php if ( bp_activity_can_comment() ) : ?> <a href="<?php bp_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf( __( 'Comment <span>%s</span>', 'buddypress' ), bp_activity_get_comment_count() ); ?></a> <?php endif; ?> <?php if ( bp_activity_can_favorite() ) : ?> <?php if ( !bp_get_activity_is_favorite() ) : ?> <a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e( 'Mark as Favorite', 'buddypress' ); ?>"><?php //_e( 'Favorite', 'buddypress' ); ?></a> <?php else : ?> <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( 'Remove Favorite', 'buddypress' ); ?>"><?php //_e( 'Remove Favorite', 'buddypress' ); ?></a> <?php endif; ?> <?php endif; ?> <?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link(); ?> <?php do_action( 'bp_activity_entry_meta' ); ?> <?php endif; ?> </div> </div> <?php do_action( 'bp_before_activity_entry_comments' ); ?> <?php if ( ( is_user_logged_in() && bp_activity_can_comment() ) || bp_is_single_activity() ) : ?> <div class="activity-comments"> <?php bp_activity_comments(); ?> <?php if ( is_user_logged_in() ) : ?> <form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>> <div class="ac-reply-avatar rounded"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ); ?></div> <div class="ac-reply-content"> <div class="ac-textarea"> <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input bp-suggestions" name="ac_input_<?php bp_activity_id(); ?>"></textarea> </div> <input type="submit" name="ac_form_submit" value="<?php _e( 'Post', 'buddypress' ); ?>" /> <a href="#" class="ac-reply-cancel"><?php _e( 'Cancel', 'buddypress' ); ?></a> <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" /> </div> <?php do_action( 'bp_activity_entry_comments' ); ?> <?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ); ?> </form> <?php endif; ?> </div> <?php endif; ?> <?php do_action( 'bp_after_activity_entry_comments' ); ?> <div class="activity-timeline"></div> </li> <?php do_action( 'bp_after_activity_entry' ); ?>
Here is activity-video-entry.php:
COPY CODE<div class="article-media"> <?php //oEmbed video $video = get_cfield('_kleo_embed'); // video bg self hosted $bg_video_args = array(); $k_video = ''; if ( get_cfield('video_mp4') ) { $bg_video_args['mp4'] = get_cfield('video_mp4'); } if ( get_cfield('video_ogv') ) { $bg_video_args['ogv'] = get_cfield('video_ogv'); } if ( get_cfield('video_webm') ) { $bg_video_args['webm'] = get_cfield('video_webm'); } if ( !empty($bg_video_args) ) { $attr_strings = array( 'preload="0"' ); if (get_cfield( 'video_poster' ) ) { $attr_strings[] = 'poster="' . get_cfield( 'video_poster' ) . '"'; } $k_video .= '<div class="kleo-video-wrap"><video ' . join( ' ', $attr_strings ) . ' controls="controls" class="kleo-video" style="height: 100%; width: 100%;">'; $source = '<source type="%s" src="%s" />'; foreach ( $bg_video_args as $video_type => $video_src ) { $video_type = wp_check_filetype( $video_src, wp_get_mime_types() ); $k_video .= sprintf( $source, $video_type['type'], esc_url( $video_src ) ); } $k_video .= '</video></div>'; echo $k_video; } // oEmbed elseif (!empty($video)) { global $wp_embed; echo apply_filters('kleo_oembed_video', $video); } ?> </div><!--end article-media--> <?php if (has_post_thumbnail( $blogpost_id ) ) : $theimg = wp_get_attachment_image_src( get_post_thumbnail_id( $blogpost_id ) ); ?> <a href="<?php echo get_post_permalink($blogpost_id); ?>"> <img style="thumbnail" style="width:100%;" src="<?php echo $theimg[0]; ?>"></a> <?php endif; ?>
February 27, 2015 at 01:22 #47909sharmstrModeratorHmmm. I just looked at my CPTs where I’ve used Kleo meta boxes and they display fine with get_cfield.
All get_cfield does is use WPs get_post_meta() but appends _kleo_ to the field.
I would do two things. Try using get_post_meta() and echoing the result. Also go into the db and make sure the field is getting set correctly.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 27, 2015 at 09:36 #47941revonorwayParticipantHello, thanks for the help. I manage to get_post_meta, and echo it. It seems like the problem might then be with this section of the code:?
COPY CODEelseif (!empty($video)) { global $wp_embed; echo apply_filters('kleo_oembed_video', $video); }
Instead of embedding the video, it just returns the video url…
March 2, 2015 at 10:11 #48329revonorwayParticipantHello, hope we can resolve this somehow… Have you tried to replicate this problem? Is it the ‘kleo_embed_video’ that is causing problems? Thanks for your help
March 2, 2015 at 15:09 #48352sharmstrModeratorNo, I haven’t. It works with regular posts and works with the CPTs I use, so its not a bug.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.