Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div>
  <h1>WP REST API Links Example</h1>
  <p><strong>Proof of concept:</strong> A list of all links embedded in recent blog posts on <a href="https://briancoords.com/tech/embedded-links-wp-rest-api/">my blog</a>. Content is pulled from WP REST API and parsed using good ol' jQuery. Feel free to replace <code>var mySite</code> with any site running WordPress 4.7+.</p>
  <ul class="links"></ul>
</div>
            
          
!

CSS

            
              body{
  color: #494949;
  font-family: -apple-system, BlinkMacSystemFont, 
    "Segoe UI", "Roboto", "Oxygen", 
    "Ubuntu", "Cantarell", "Fira Sans", 
    "Droid Sans", "Helvetica Neue", sans-serif;
  line-height: 1.4;
}

div{
  width: 600px;
  max-width: 100%;
  margin:0 auto;
}

ul{ 
  list-style-type: none;
  margin: 0;
  padding: 0;
  li {
    word-break: break-all;
    ul {
      list-style-type: disc;
      padding-left: 40px;
      margin-bottom:  20px;
    }
  }
}

a {
  text-decoration: none;
  color: #1E88E5;
}
            
          
!

JS

            
              // Get all link urls using WP REST API

// Put in WordPress site url here:
var mySite = 'https://briancoords.com';

// Get REST API URL
var url = mySite + "/wp-json/wp/v2/posts";  

// Load REST API URL
$.getJSON( url, function( data ) { 

  // Loop through each post
  $.each( data, function( i, item ) {

    // Create array of urls in post content
    var urls = $(item.content.rendered).find('a');
    
    // Add post title if urls exist
    if(urls){
      
      $('.links').append('<li><strong>' + item.title.rendered + '</strong> <a href="' + item.link + '">🔗</a> <ul class="links-'+item.id+'">');
      
    }

    // Loop through array of URLS
    $.each( urls, function(i, el){

      // Prettify URL
      var prettyUrl = el.href.split('/')[2];
      
      if(prettyUrl.startsWith('www.')){
        prettyUrl = prettyUrl.slice(4);
      }
      
      // Appeand links to UL
      $('.links-' + item.id ).append('<li><a href="' + el.href + '">' + el.text + '</a> (' + prettyUrl + ')</li>');

    });

    // End sub li & ul if urls exist
    if(urls){
      
      $('.links').append('</li></ul>');
      
    }

  });

});
            
          
!
999px

Console