Update WordPress theme for licensed content

  • Updated

A web developer must update PHP files after integrating the Content Marketing Platform (CMP) with your WordPress site (under CMS Accounts). 

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 it by going to Screen Options and selecting Custom Fields.


  • nc-author – The author from the publisher. If you publish licensed content, you must 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 serves as a canonical link for licensed content and should be displayed when such content is in use.

    You will see a GUID in this field if the publisher does not provide this link. 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

Using custom fields in the CMP, you can pass additional data (such as images, videos, or values for plugins you are using) to WordPress. 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 code in a staging environment before adding it to your site.

You may need 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 the theme

To show the correct author and publisher information, edit the 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 drop-down 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 the Yoast SEO plugin, you should deactivate 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;