Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. Question: Adding video to the Headline section in Arthemia. I want to retain the current functionality for the headline category whereby a post is shown on the main page with the thumbnail and text. However, I also want to create a new category called "Video" which if selected, will allow me to populate a single video from Vimeo into the headline section.

    Answer: It is easier to use an other custom field called 'Video' where you insert the full embed code of the video. In the query for Headline posts we ask first if there is a custom field 'Video'. If this custom field is assigned to a post from category Headline, echo out the video code. If there is no custom field video, use 'else' and display the image and excerpt as ususal.

    I give you here a part of the code of index.php of Arthemia free version, modified to display a video if you assign custom field name: Video and a Value with the full code as you get from Vimeo or Youtube to embed a clip on your site:

    <div id="headline">
    		<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/headline.png" width="75px" height="21px" alt="" />
    		<?php query_posts("showposts=1&category_name=Headline"); ?>
    		<?php while (have_posts()) : the_post(); ?>
    <!-- first new part, check for customfield Video -->
    <?php $videovalues = get_post_custom_values("Video"); if (isset($videovalues[0])) { ?>
    <div id="headlinevideo">
    <?php echo $videovalues[0]; ?>
    </div>
    <?php } else { ?>
    <!-- end first new part -->
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>
    	<?php $values = get_post_custom_values("Headline");?>
     	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=300&h=275&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="300px" height="275px"  /></a>
    	<?php the_excerpt(); ?>
    	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read the full story &raquo;</a>
    <!-- second new part, end else do normal stuff -->
    <?php } // end if video or else normal ?>
    <!-- end second new part -->
    	<?php endwhile; ?>
    		</div>
    	<div id="featured">

    Actually I inserted two pieces here, first above <div class="title"> and second just before the <?php endwhile; ?> of Headline part.
    The Video code is in a new div id="headlinevideo" so you can style it as you like, ie put in style.css this:

    #headlinevideo {
    	margin:5px;
    	text-align:center;
    	}

    this should center the video and give some space around.

    Happy coding, you are welcome to ask here if you get problems

    Posted 2 years ago #
  2. Can I play a wmv file in this customfield?

    first: I wouldn't play a 'microsoft only' wmv file. If you use Windows Media format, you leave out your Mac visitors. If you use QuickTime (.mov), you leave out your Windows visitors.
    So convert your video to a Flash file what YouTube and Google Video use since Flash is pre-installed in more browsers.

    I can't look at your video in any browser unless I download a player from microsoft - even running win7 with it's mediaplayer.

    Did you try with a youtube video? Easiest would be to create a youtube account (use your google account if you have), upload your video as wmv and youtube will convert it to flash. finally just use the youtube embed code to link back to your video on youtube what saves you lot's of bandwidth.

    If you used the code from here:
    http://forum.go41.de/topic/video-in-headline-separate-custom-field
    to get the video customfield AND want to show an excerpt, you have to add the_excerpt under the code to grab this video.

    there is now:

    <div id="headlinevideo">
    <?php echo $videovalues[0]; ?>
    </div>

    which takes only the video custom field if there is.
    adding the excerpt below do this:

    <div id="headlinevideo">
    <?php echo $videovalues[0]; ?>
    <?php the_excerpt(); ?>
    </div>

    or even the title above the video like this

    <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    <div id="headlinevideo">
    <?php echo $videovalues[0]; ?>
    <?php the_excerpt(); ?>
    </div>

    Did this help??

    Posted 2 years ago #
  3. omarkhan
    Member

    Joern, please answer me this then.,

    1. When you add an WMV file in your Headline post of arthemia, as I have done, the navbar appears behind it. I don't think the "wmode=transparent/opaque" works with non flash based movies. Is that correct? The problem with flash is that, it doesn't have any controls. I want to use my WMV movie but I want to have the nav bar appear in front of it. Can you use a z index in CSS and make it the smallest or (-) value? If not, then would you convert the Swf into an FLV. Does that come with controls? I really need your help brother on this one.

    Thanks so much for your kindness. You can e-mail me at khkit@rogers.com

    Omar

    Posted 2 years ago #
  4. omarkhan
    Member

    Its okay I fixed the problem. Used a wonderful player called flowplayer.

    Omar

    Posted 2 years ago #
  5. raf_79
    Member

    Hello,

    I came across this topic in your forum "Video in Headline - separate custom field" at:
    http://forum.go41.de/topic/video-in-headline-separate-custom-field#post-24

    It tells how to put a video in the 'Headline' section - which is nice but that is all that's left there in that big space - a video. I'd like to know how can I just substitute a video for the picture and leave everything else (the post excerpt, the more tag) intact. Can this be done? Thanks...

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):