PHP and wp custom fields ahhhhhhhhhhhhhh help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manfap
    Confirmed User
    • Jan 2013
    • 2626

    #1

    PHP and wp custom fields ahhhhhhhhhhhhhh help

    I´m fucking about in wp with custom fields calling the video url for the flowplayer plugin and I´m getting Parse error: syntax error, unexpected T_STRING on.....

    Code:
    <?php
     flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, '_wpb_video', true); ?>]');
     ?>
    but
    Code:
    <?php flowplayer('[flowplayer src=/videos/example.flv]'); ?>
    works

    so I assumed its because I´m calling php again on the echo..
    I tried
    Code:
    <?php flowplayer('[flowplayer src=echo get_post_meta($post->ID, '_wpb_video', true)]'); ?>
    but get Parse error: syntax error, unexpected T_STRING on..... again

    it´s not pulling the echo so I tried $string

    This doesn´t break anything I actually get the page but it pulls echo as the filename
    Code:
    <?php
    $string= " <?php echo get_post_meta($post->ID, '_wpb_video', true); ?> ";
    
     flowplayer('[flowplayer src=echo $string;]'); ?>
    so I tried
    Code:
     <?php
    $string= "flowplayer('[flowplayer src=";
    $string .="echo get_post_meta($post->ID, '_wpb_video', true)";
    $string .="]')";
    echo $string;
     ?>

    which gives me
    Code:
    flowplayer('[flowplayer src=echo get_post_meta(142, '_wpb_video', true)]')
    which seems to work codewise, but its posting it as text with "" surrounding it, rather than php.

    so do I need to include <?php and ?> in the string? and it so how?
    or how do make it so it s doesnt post the code within ""

    if I do something like
    Code:
     <?php
    $string= "<?php flowplayer('[flowplayer src=";
    $string .="echo get_post_meta($post->ID, '_wpb_video', true)";
    $string .="]')" ?>;
    echo $string;
     ?>
    it doesnt complete the code due to the first ?>;

    But because of my limited php knowledge thats me stuck.. anyone got any ideas.
    Last edited by Manfap; 03-16-2013, 09:43 AM.
  • Naughty
    Confirmed User
    • Jul 2001
    • 6487

    #2
    Code:
     flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, \'_wpb_video\', true); ?>]');
    ?
    seks.ai for sale - ping me

    Comment

    • EddyTheDog
      Just Doing My Own Thing
      • Jan 2011
      • 25433

      #3
      Originally posted by Naughty
      Code:
       flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, \'_wpb_video\', true); ?>]');
      ?
      Its quotes - but not those ones - Maybe I can do it in the morning...

      Comment

      • Naughty
        Confirmed User
        • Jul 2001
        • 6487

        #4
        Did you actually echo the function??
        seks.ai for sale - ping me

        Comment

        • Manfap
          Confirmed User
          • Jan 2013
          • 2626

          #5
          wow that was quick.. thx for the replies.
          Originally posted by Naughty
          Did you actually echo the function??
          The flowplayer is pulled as
          Code:
          <?php flowplayer('[flowplayer src=videos/example.flv]'); ?>
          which is how they tell you to on their site
          foliovision. com/seo-tools/wordpress/plugins/fv-wordpress-flowplayer

          and works, it´s when I start messing with the content, switching it to pulling from a custom field it all goes pear-shaped and that is getting pulled on an echo.
          Code:
          <?php flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, '_wpb_video', true); ?>]'); ?>
          or did you mean something else?

          I tried
          Code:
          ]<?php flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, \'_wpb_video\', true); ?>]'); ?>
          the player parses now but pulls the vid url as sitename.com/<?php

          Originally posted by EddyTheDog
          Its quotes - but not those ones - Maybe I can do it in the morning...
          thx.
          Last edited by Manfap; 03-16-2013, 10:21 AM.

          Comment

          • hulker
            Registered User
            • Mar 2013
            • 26

            #6
            Something like this should work php wise :



            <?php
            $postMeta = get_post_meta($post->ID, '_wpb_video', true);
            ?>

            flowplayer('[flowplayer src=<?php echo $postMeta ?>]');
            pervypig.com

            Comment

            • Colmike9
              (>^_^)b
              • Dec 2011
              • 7230

              #7
              <?php
              flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, '_wpb_video', true); ?>]');
              ?>

              You're getting the parse error because you are trying to php echo inside an already open php call.. Try to concatenate the strings instead.
              Join the BEST cam affiliate program on the internet!
              I've referred over $1.7mil in spending this past year, you should join in.
              I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..

              Comment

              • Manfap
                Confirmed User
                • Jan 2013
                • 2626

                #8
                Originally posted by hulker
                Something like this should work php wise :



                <?php
                $postMeta = get_post_meta($post->ID, '_wpb_video', true);
                ?>

                flowplayer('[flowplayer src=<?php echo $postMeta ?>]');
                that returns the correct code



                Code:
                flowplayer('[flowplayer src=/2/2E/2EBBC2H3H0/8/0/7/1/c11708/fb43ba21e2/11708_01/01/11708_01_120sec_00.mp4]');
                but as text if I php this flowplayer('[flowplayer src=<?php echo $postMeta ?>]'); it shows the player but doesnt pull the correct url for the vid it returns sitename.com/<?php... as the video


                Originally posted by Colmike7
                <?php
                flowplayer('[flowplayer src=<?php echo get_post_meta($post->ID, '_wpb_video', true); ?>]');
                ?>

                You're getting the parse error because you are trying to php echo inside an already open php call.. Try to concatenate the strings instead.
                Seems when I try and return the string I can get the code.. but then it doesnt treat the flowplayer as php it shows as text.



                Serves me right for trying to be clever.. hehe.

                Comment

                • Manfap
                  Confirmed User
                  • Jan 2013
                  • 2626

                  #9
                  Solved it

                  Code:
                  <?php
                  	$vid = get_post_meta($post->ID, '_wpb_video', true);
                  	$splash = get_post_meta($post->ID, '_wpb_poster', true);
                  { echo flowplayer( '[flowplayer src="' . $vid . '" width=580 height=326 splashend=show splash="' . $splash . '" autoplay=true]'); } ?>
                  Incase anyone ever needs to pull a vid from a custom field using flowplayer in wp.
                  this works.
                  Last edited by Manfap; 03-16-2013, 12:07 PM.

                  Comment

                  Working...