Blog

Embed a YouTube Video in ClassiPress using a custom field

Tested on WordPress 4.0  &  ClassiPress Version: 3.3.3

While reading some threads in the ClassiPress forums about embedding a YouTube video in ClassiPress listings, i figured out a nice way how to accomplish this using the custom fields and form layouts. The advantage of this way is that you don’t need to care if html is enabled or not. Your customers just need to place the YouTube video ID into a custom field that we create in this tutorial. So let’s start getting this done.

I assume that you have ClassiPress and your own child theme running. Time to get started:

Step 1.

The files we need to customize are:

  • single-ad_listing.php
  • style.css

As we don’t change core files directly, we just take a copy of those php files and add them to our child theme folder. Now we start to edit our copies.

Open your /childtheme/single-ad_listings.php and find around line 122 this part of code:

Above that line you place this:

please-read

Dear visitor. Embed a YouTube Video in ClassiPress using a custom field is a premium article. If you would like to get access to the rest of this article, please pay $ 3.45 USD fee to help me keeping this site alive. After your payment is done you will automatically receive an Email that includes an activation link. Please Note: The activation link is valid for 2 days.

Tags: , , , , , , ,

12 Responses to “Embed a YouTube Video in ClassiPress using a custom field”

  1. Henrique August 22, 2013 at 01:19 #

    Good night, my ClassiPress 3.3 in option: ClassiPress => Custom Fields => Add New => not appear “” META NAME “,” what can I do?

    • Rolf Hassel August 22, 2013 at 06:35 #

      Hi Henrique,

      Fill out all the other fields like in the above screenshot. After you save it, the meta name gets created.

      Cheers

  2. Henrique August 22, 2013 at 18:00 #

    Thank you, I succeeded. xD

  3. mr green August 23, 2013 at 11:54 #

    You miss a part here Go deeper

    Explain how to remove the extra filed created near the picture right after the other meta meta filed
    That make non-sens for reader because is intelligent as possible: PcxvIxaC91s

    Do that with a simple display none
    in your case it will apply to

    Need conditional in css because you can remove the same field in user input form AD
    The field is commune for the 2 pages

    .bigright > ul #cp_youtube_video_id {
    display: none;
    }

    • Rolf Hassel August 23, 2013 at 13:12 #

      Thanks mr_green for that additional condition in the style.css, as it can be used if somebody doesn’t want the video ID to show up in the single ad descriptions. This can be used on personal requirements.

      Cheers

  4. Arivederchi September 1, 2013 at 05:47 #

    This is absolutely a wonderful tutorial…Thank you so much for taking the time to put it together. This definitely will make the user experience a bit easier. Now, like most people I do have some questions…keeping fingers crossed:-)

    1. Is it possible for the entire url to be posted instead of just the Id? This would make things even easier for the user, which is what we want right!

    2. Would it be possible to include another video site url such as Vimeo?

    Just thought I would throw my thoughts out there…Thanks again for your wonderful tutorials!

  5. Artem Frolov September 1, 2013 at 18:42 #

    Hi, Rolf!
    Great site!

    Can i give couple advices?
    1. appthemes_after_post_content() – is the hook. Just use to add your additional code. No need paste code directly to the template.
    2. If you do first, you can add styles for .videoContainer directly to your html tag. So no need add this line to any file.

    Best Regards!

    Artёm

    • Rolf Hassel October 10, 2013 at 11:41 #

      Hi Artem, but that code gets placed ABOVE that line.

  6. Arivederchi October 26, 2013 at 17:11 #

    Hi Rolf! Haven’t heard a response to my post, any thoughts?

  7. Carvalho February 15, 2014 at 17:31 #

    I followed all the steps, but the video will not appear in the ad.

    • Rolf Hassel February 15, 2014 at 17:50 #

      I can see that you did several changes in other places. Maybe one of them gets in conflict? I can’t tell you why it doesn’t work on YOUR site. This tutorial was used many times and never had any problems. Please check again if you followed all the steps exactly as explained.

      Cheers

  8. Carvalho February 24, 2014 at 20:38 #

    I had to back up on my website, and it seems that the target name already exists and therefore I can not create the name meta cp_youtube_video_id again, can you tell me where the custom fields in the ClassiPress folder? so I can delete it and re-add.

Leave a Reply


8 + = 16

Go Up ▲Go Up ▲