Crear Custom Field en Wordpress con Video Embed

  • Autor Autor villabull
  • Fecha de inicio Fecha de inicio
V

villabull

Hola FB, tengo una duda que por mas que leo no la puedo solventar.

Deseo crear un custom Field en wordpress de la siguente manera:

jEcvRCP.jpg


Donde el Name del custom field (titulado como "RVideo") llame el siguiente codigo:

Insertar CODE, HTML o PHP:
<embed src="http://embed.sitio.com/player/?id=[COLOR="#FF0000"]290883[/COLOR]" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">

Y en el Value solo ingresar el id del video 290883
 
NO es muy dificil, puedes hacerlo de esta forma:

Despues de :
Insertar CODE, HTML o PHP:
 <?php while ( have_posts() ) : the_post(); ?>

Pones por ejemplo
Insertar CODE, HTML o PHP:
<?php $video = get_post_meta($post->ID, "Rvideo"); ?>

y luego ya en tu codigo que quieres, pones:
Insertar CODE, HTML o PHP:
<?php if($video !== '') { ?>
<embed src="http://embed.sitio.com/player/?id=<?php echo $video; ?>" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">
<?php } ?>

Y con eso queda :encouragement:
 
NO es muy dificil, puedes hacerlo de esta forma:

Despues de :
Insertar CODE, HTML o PHP:
 <?php while ( have_posts() ) : the_post(); ?>

Pones por ejemplo
Insertar CODE, HTML o PHP:
<?php $video = get_post_meta($post->ID, "Rvideo"); ?>

y luego ya en tu codigo que quieres, pones:
Insertar CODE, HTML o PHP:
<?php if($video !== '') { ?>
<embed src="http://embed.sitio.com/player/?id=<?php echo $video; ?>" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">
<?php } ?>

Y con eso queda :encouragement:

Gracias, lo hice y queda en blanco porq la direccion la reconoce como:
http://embed.sitio.com/player/?id=Array

El codigo que tu me dijiste va en single.php verdad?
 
Prueba con esto.!!

HTML:
<embed src="http://embed.sitio.com/player/?id=<?php echo get_post_meta( $post->ID, "Rvideo", true ); ?>" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">
 
si va en single

No se que esta mal, el value no lo capta, en su lugar la url queda así:
http://embed.sitio.com/player/?id=Array

---------- Post agregado el 06-jul-2013 hora: 22:43 ----------

Prueba con esto.!!

HTML:
<embed src="http://embed.sitio.com/player/?id=<?php echo get_post_meta( $post->ID, "Rvideo", true ); ?>" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">


Gracias, tu codigo lo cologo siempre entre:

Insertar CODE, HTML o PHP:
[COLOR="#FF0000"]<?php if($video !== '') { ?>[/COLOR]
<embed src="http://embed.sitio.com/player/?id=<?php echo get_post_meta( $post->ID, "Rvideo", true ); ?>" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">
[COLOR="#FF0000"]<?php } ?>[/COLOR]

Lo rojo?

---------- Post agregado el 06-jul-2013 hora: 22:46 ----------

PHP:
<?php
/**
 * The Template for displaying all single posts.
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); ?>

	<div id="primary" class="site-content">
		<div id="content" role="main">

			<?php while ( have_posts() ) : the_post(); ?>
<?php $video = get_post_meta($post->ID, "Rvideo"); ?>
<?php if($video !== '') { ?>
<embed src="http://embed.sitio.com/player/?id=<?php echo get_post_meta( $post->ID, "Rvideo", true ); ?>" quality="high" width="425" height="350" type="application/x-shockwave-flash" allownetworking="internal" allowscriptaccess="never" autoplay="false" wmode="transparent">
<?php } ?>

				<?php get_template_part( 'content', get_post_format() ); ?>

				<nav class="nav-single">
					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
				</nav><!-- .nav-single -->

				<?php comments_template( '', true ); ?>

			<?php endwhile; // end of the loop. ?>

		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>


Este codigo tengo en single.php

---------- Post agregado el 06-jul-2013 hora: 22:55 ----------

Ya funciona, gracias, [MENTION=2218]Angel Ortega[/MENTION] , [MENTION=1597]YeltsinGraphs[/MENTION] !
Pero ahora sale en todos los post, (por estar en single.php) alguna idea para que solo salga en el cuerpo del articulo?
 
No deberia salir en todos, si lo pones en single.php, para eso es el if(), para que solo salga si tiene valor el customfield y tomando el valor que le des a cada post
 
Para que solo se muestre el código cuando se le asigne un valor al customfield envuelve todo el código que necesites de esta manera:

Insertar CODE, HTML o PHP:
 <?php if ( get_post_meta($post->ID, '[COLOR="#FF0000"]xxxx[/COLOR]', true) ) : ?>

MI CODIGO VA AQUÍ!!!

<?php endif; ?>

Cambiando las xxxx por el id del custom field y MI CODIGO VA AQUÍ!!! seria el embed!
 
Atrás
Arriba