Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

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.

  <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>
  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;

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

  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;
              // Get all link urls using WP REST API

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

var url = mySite + "/wp-json/wp/v2/posts";  

$.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
      $('.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];
        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


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.