• Resolved CRE8

    (@cre8gr)


    Hello,

    I use you plugin for a website that is required to have more than one authors.

    I also use the plugin royalslider to have some slides in the homepgage. My question is how to include both authors in the royalslider slide?

    Before I use co-author, I was using Advanced Custom Fields plugin to display the author that was set using the following code:

    function newrs_add_acf_variable($m, $data, $options) {
    
        $m->addHelper('display_name', function() use ($data) {
    			// $data is a WordPress post object (for posts-slider)
    
    			// just return value
    			$field_value = get_field('editor_name', $data->ID );
    			return $field_value['display_name'];
        });
    
    }
    add_filter('new_rs_slides_renderer_helper','newrs_add_acf_variable', 10, 4);

    And then I just used the following variable in the RoyalSlider HTML Markup to include the author: {{display_name}}.

    My question is how can I include both post authors using Royalslider and Co-Author plus?

    https://wordpress.org/plugins/co-authors-plus/

Viewing 1 replies (of 1 total)
  • Thread Starter CRE8

    (@cre8gr)

    Nevermind, I found a way!

    Google is our friend, so I found this: https://wordpress.org/support/topic/get-id-inside-coauthorsiterator?replies=2. Edited the code to my needs and ta-da, it works!!!

    For anyone who wants to do the same thing then this is what worked for me (put the code inside functions.php file):

    function newrs_add_acf_variable($m, $data, $options) {
        $m->addHelper('display_name', function() use ($data) {
    	// $data is a WordPress post object (for posts-slider)
    
    	// just return value
    	$new_coauthor = '';
    	$coauthors = get_coauthors($data->ID);
    	foreach( $coauthors as $coauthor ) {
    		$new_coauthor .= $coauthor->display_name.', ';
    	}
    	$the_coauthor = rtrim($new_coauthor, ', ');
    	return $the_coauthor;
        });
    }
    add_filter('new_rs_slides_renderer_helper','newrs_add_acf_variable', 10, 4);
Viewing 1 replies (of 1 total)
  • The topic ‘RoyalSlider and Co-Author’ is closed to new replies.