• Resolved KrissieV

    (@krissiev)


    I’m wondering if there is a way to have a permalink to each individual video without having to create a new page and drop in the shortcode. I can put
    <?php echo do_shortcode( '[flowplayer id="33"]' ) ?>
    in my template file and use a variable to get the id to use. I thought I might be able to tweak this myself, but I’m not having much luck.

    https://www.ads-software.com/plugins/flowplayer5/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ulrich

    (@grapplerulrich)

    At the moment not, I will be adding this in a future release. I need to rethink a few a things.

    Thread Starter KrissieV

    (@krissiev)

    Thanks! For the time being, I’ve got a script in my functions.php that’s automatically adding a new page (if one doesn’t exist already) with the same title as the video when the video is saved, and inputs the shortcode into the page and saves the video id as a variable for use in pulling out some custom fields I’ve added. Not ideal, but it’s working for this instance.

    Plugin Author Ulrich

    (@grapplerulrich)

    Could you share this code? I would be interested.

    Thread Starter KrissieV

    (@krissiev)

    A friend helped me put it together, so I can’t take credit for it, but here it is. Hasn’t really been tested very adequately, just in my unique instance.

    //Generate New Page from Video
    function copy_videos_to_pages( $post_id ) {
    	// Only if we're saving a flowplayer5 video
    	if ( 'flowplayer5' !== get_post_type( $post_id ) )
    		return;
    
    	// Get $post object for video currently being saved
    	$video = get_post( $post_id );
    
    	$page_title = get_page_by_title( $video->post_title, '', 'page' );
    
    	//Prevent Infinite Loop -  https://codex.www.ads-software.com/Plugin_API/Action_Reference/save_post#Avoiding_infinite_loops
    	remove_action( 'save_post', 'copy_videos_to_pages' );
    
    	/**
    	 * Check to see if a Page with the same title as this Video exists.
    	 * If not, create a new Page
    	 * Not totally foolproof, but a simple check.
    	 */
    	if ( is_null( $page_title ) ) {
    
    		//Create new Page that includes content from Video
    		$my_post = array(
    			'post_title'   => $video->post_title,
    			'post_date'    => $video->post_date,
    			'post_content' => '[flowplayer id="' . $video->ID . '"]',
    			'post_type'    => 'page',
    			'post_status'  => 'publish',
    			);
    
    		$post_id = wp_insert_post($my_post);
    
    		add_post_meta($post_id, 'related_video', $video->ID, true);
    
    	} else {
    
    		//do nothing
    
    	}
    
    	add_action( 'save_post', 'copy_videos_to_pages', 10, 1 );
    
    }
    add_action( 'save_post', 'copy_videos_to_pages', 10, 1 );
    Plugin Author Ulrich

    (@grapplerulrich)

    Thanks, it looks good.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘permalink’ is closed to new replies.