Update WordPress theme for licensed content

  • Updated

After you integrate the Content Marketing Platform (CMP) with your WordPress site (under CMS Accounts), a web developer needs to update PHP files. 

Default fields (author and source of an article)

By default, every article that the CMP posts to WordPress includes the following data in the Custom Fields section of the post entry.

If the Custom Fields section does not show at the bottom of a post, you may need to enable them by going to Screen Options and selecting Custom Fields.


  • nc-author – The author from the publisher. If you are publishing licensed content, you will need to edit your theme files to display the provided author instead of the default WordPress user.
  • nc-image-link – The link to the featured image of the article.
  • nc-link – The link to the article on the publisher's site, serving as a canonical link for licensed content, and should be displayed when such content is in use.

    If the publisher does not provide this link, you will see a GUID in this field. Contact Support.

  • nc-source – The name of the publication. You should put this value in the byline next to the author attribution.

A properly set up theme looks similar to the following image:


Additional custom fields

You can pass additional data (such as images or videos, or providing values for plugins that you are using) to WordPress using Custom Fields in the CMP. Contact your Customer Success team for help setting up Custom Fields. 

Code samples

The code samples in this section show how to implement changes to your theme.  Test all code in a staging environment prior to adding to your site. You may nee to adjust the code samples  based on your theme.

Code for surfacing author and publisher information

Drop this into functions.php to generate an "author, source" string.
The function generate_license_info produces a formatted string with author and source name for use in the theme file that display the post.

function generate_license_info() {
   $license = '';
   $nc_author = get_post_meta(get_the_id(), 'nc-author', 1); // Pull in the author custom-field
   $nc_source = get_post_meta(get_the_id(), 'nc-source', 1); // Pull in the source custom-field ``` // Check if both the nc-author & nc-source field aren't empty, then assign it to $license string

   if ( $nc_author != '' )
      $license = $nc_author;

   if ( $nc_source != '' )
      $license = $nc_source; // Join the author name & source name together, separated by a comma for a complete byline.

   if ( $nc_author != '' && $nc_source != '' )
      $license = $nc_author . ' | ' . $nc_source;
      return $license;

Code for displaying author and publisher info in theme

To show the correct author and publisher information, edit the specific theme file for single posts. You should create a WordPress user named CMPuser when you initially connect your site to the CMP. When you publish licensed content, choose the CMPuser from the list of authors in the article task as depicted below.

/* For use in theme file where post is displayed. 
You should set up a WordPress user called 'CMPuser' when initially connecting to CMP.
When publishing licensed content, choose the 'CMPuser' user. */

if ('CMPuser' == get_the_author_meta('user_login'))
else {

// Replace the above line of code with the theme's default function to display author information 
// (usually 'the_author()' in standard WordPress setups)

Add a canonical link

To display canonical links correctly for licensed content, add the following code to your theme's header.php file.

If you are using Yoast SEO plugin, you should disable the canonical link on single post pages. You can do this by adding the second snippet of code to your functions.php file.

Canonical in header

$canonical_url = get_post_meta( $post->ID, 'nc-link', true);

if (is_single() && !empty($canonical_url)) {
     <link rel="canonical" href="<?php echo $canonical_url ?>"/>
else {
     <link rel="canonical" href="<?php the_permalink(); ?>"

Disable Yoast SEO on post pages

(Only applies if Yoast is in use)

function wpseo_canonical_exclude($canonical) {
global $post; 

if (is_single()) {
    $canonical = false; 
 return $canonical;