• Resolved alexcox

    (@alexcox)


    Hi,

    I am looking to switch to WP Native Articles to simplify the creation process on my site. The only thing currently holding me back is the ability to specify branded content partners.

    Is there something I can add to functions to make this work?

    The format in facebook is as follows

    <ul class="op-sponsors">
    <li>
    <a href="https://facebook.com/partinera" rel="facebook"></a>
    </li>
    <li>
    <a href="https://facebook.com/partinerb" rel="facebook"></a>
    </li>
    </ul>

    Thank you in advance

    Alex

    • This topic was modified 6 years, 10 months ago by alexcox.
    • This topic was modified 6 years, 10 months ago by alexcox.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author OzTheGreat

    (@ozthegreat)

    Hi Alex,

    Thanks for getting in touch. Yep we support that. On each individual post you can override any of the global default values set. One of those options is to make the post a sponsored one (screenshot: https://prnt.sc/hxm2e0). If you set it to ‘Enabled’ then it checks the Author(s) profile from a ‘facebook’ field (this is the default field the Yoast SEO Plugin adds that allows you to add Facebook profiles to users) and uses that to construct the links exactly as you’ve described above.

    I hope that all makes sense? If you have nay more questions or have any issues please do get in touch!

    All the best

    • This reply was modified 6 years, 10 months ago by OzTheGreat. Reason: Add screenshot
    Thread Starter alexcox

    (@alexcox)

    thank you for the swift reply ?? Ideally we need to be able to add and remove these on a per post basis. Its 3 sponsors max.

    Unfortunately using the Author page would not allow this and make a globe change when we have to change them.

    Plugin Author OzTheGreat

    (@ozthegreat)

    Hi Alex,

    Ahh I see, so the article authors won’t necessarily be the sponsored ones. Err no I’m afraid it can’t do that at the moment, it just assumes they’re the same. However, I’ve had a look and it’s not hard to add in. If you do decide to give it ago then you can add the code below to add an extra field at the bottom of the Content tab for each post. You can then add as many profiles as you like separated by a comma. It’s actually quite a good feature and I think we may add it in permanently in one of the upcoming releases.

    All the best

    /**
     * Output the HTML for the custom authors field.
     *
     * @return void
     */
    function wpna_custom_sponsored_authors() {
    	?>
    	<h3><?php esc_html_e( 'Custom Sponsored Authors', 'wp-native-articles' ); ?></h3>
    	<p class="description"><?php esc_html_e( 'Set custom sponsored authors. Should be links to Facebook profiles separated by commas.', 'wp-native-articles' ); ?></p>
    	<fieldset>
    		<div class="pure-control-group">
    			<label for="fbia_custom_authors"><?php esc_html_e( 'Custom Sponsored Authors', 'wp-native-articles' ); ?></label>
    			<input type="text" name="wpna_options[fbia_custom_authors]" id="fbia_custom_authors" class="" value="<?php echo esc_attr( get_post_meta( get_the_ID(), '_wpna_fbia_custom_authors', true ) ); ?>" />
    		</div>
    	</fieldset>
    	<?php
    }
    add_action( 'wpna_post_meta_box_facebook_custom_content_footer', 'wpna_custom_sponsored_authors', 10 );
    
    /**
     * Reigster fields that should be saved in the post meta.
     *
     * @param  array $fields Fields that should be saved.
     * @return array $fields
     */
    function wpna_custom_post_meta_box_custom_authors( $fields ) {
    	$fields[] = 'fbia_custom_authors';
    	return $fields;
    }
    add_filter( 'wpna_post_meta_box_fields', 'wpna_custom_post_meta_box_custom_authors', 10, 1 );
    add_filter( 'wpna_sanitize_post_meta_fbia_custom_authors', 'sanitize_text_field', 10, 1 );
    
    function wpna_custom_sponsored_authors_output() {
    	$custom_authors = get_post_meta( get_the_ID(), '_wpna_fbia_custom_authors', true );
    
    	if ( ! empty( $custom_authors ) ) {
    		$authors = explode( ',', $custom_authors );
    		$authors = array_filter( $authors );
    		$authors = array_map( 'trim', $authors );
    
    		$output = '<ul class="op-sponsors">' . PHP_EOL;
    		foreach ( $authors as $author_url ) {
    			$output .= sprintf( '<li><a href="%s" rel="facebook"></a></li>', esc_url( $author_url ) ) . PHP_EOL;
    		}
    		$output .= '</ul>';
    
    		echo $output;
    	}
    
    }
    add_action( 'wpna_facebook_article_content_header', 'wpna_custom_sponsored_authors_output', 10 );
    
    Thread Starter alexcox

    (@alexcox)

    Perfect, thats worked a treat

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Co Branded Content Sponsors’ is closed to new replies.