• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Converting HTML to shortcode

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Converting HTML to shortcode

This topic is: resolved

Tagged: complex code, html, javascript, shortcodes

  • This topic has 1 reply, 1 voice, and was last updated 10 years, 3 months ago by Eric Emanuel.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 30, 2015 at 2:34 pm #175231
    Eric Emanuel
    Member

    Hello, everyone

    I've been studying how to create shortcodes and have found some good examples of how to do it, but I'm using a more complex HTML code and can't figure out how to "translate" this to Javascript.

    This is the HTML code I've been using to create a div with movie background and two phrases over it. Can you help me with the Javascript that outputs this code and allow me to control the variables inside it?

    <section class="content-section video-section">
    <div class="pattern-overlay">
      <a id="bgndVideo" class="player" data-property="{videoURL:'https://www.youtube.com/watch?v=fdJc1_IBKJA',containment:'.video-section', quality:'large', autoPlay:true, mute:true, opacity:1}">bg</a>
        <div class="container">
          <div class="row">
            <div class="col-lg-12">
            <h1>Full Width Video</h1>  
            <h4>Enjoy Adding Full Screen Videos to your Page Sections</h4>
            </div>
          </div>
        </div>
      </div>
    </section> 

    Thanks!

    December 30, 2015 at 10:53 pm #175256
    Eric Emanuel
    Member

    Ok, it took some time but I was able to find a solution by myself. The main problems were:

    1. There's a great number of variables in this code
    2. Some of them use "double-quotes" and others use 'single-quotes', so you have to carefully organize interchange these two. It's very, very easy to make mistakes here.
    3. I have no idea why, but using 'videoURL' as a variable didn't work, I had to change it to 'videolink' in this case. I guess it's a conflict, but I'm not sure about that.

    The strategy that saved me was looking into the font-code generated by the browser. The point of the shortcode is to generate exactly the same HTML code as above if there's no user input, so I only had to look at the generated code, compare with my original code and fix the problems. Patience is important here.

    The result is: I can now create divs with video background and text over it only writing this in any page:

    [video]
    [videoitem videolink="https://www.youtube.com/watch?v=fdJc1_IBKJA" title="This is a Title" subtitle="This is a subtitle"][/videoitem]
    [/video]

    For the curious, this is the CSS I'm using:

    .video-section .pattern-overlay {
    	background-color: rgba(71, 71, 71, 0.59);
    	padding: 110px 0 32px;
    	min-height: 496px; 
    	/* Incase of overlay problems just increase the min-height*/
    }
    
    .video-section h1, .video-section h4{
    	text-align:center;
    	color:#fff;
    }
    
    .video-section h1{
    	font-size:110px;
    	text-transform: uppercase;
    	margin: 40px auto 0px;
    	text-shadow: 1px 1px 1px #000;
    	-webkit-text-shadow: 1px 1px 1px #000;
    	-moz-text-shadow: 1px 1px 1px #000;
    }
    
    .video-section h4{
    	font-size: 25px;
    	margin: 0px auto 15px;
    }
    
    .video-section .buttonBar{
    	display: none;
    }
    
    .player {
    	font-size: 1px;
    }

    Awesome! =D

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Converting HTML to shortcode’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble