• Resolved phoenixsa07

    (@phoenixsa07)


    Hello!
    I would like to display the copyright credits manually under the featured image. I have the following code in the file functions.php:

    =================================
    //* Add featured image on single post
    add_action( ‘genesis_entry_content’, ‘maker_featured_image’, 1 );
    function maker_featured_image() {

    $add_single_image = get_theme_mod( ‘maker_single_image_setting’, true );

    $image = genesis_get_image( array(
    ‘format’ => ‘html’,
    ‘size’ => ‘featured-image-large’,
    ‘context’ => ”,
    ‘attr’ => array ( ‘alt’ => the_title_attribute( ‘echo=0’ ), ‘class’ => ‘aligncenter’ ),
    ) );

    if ( is_singular() && ( true === $add_single_image ) ) {
    if ( $image ) {
    printf( ‘<div class=”featured-image”>%s<div class=”featured-image-credits”><p class=”copyright-info”>’NEED CODE TO DISPLAY COPYRIGHT'</p></div></div>’, $image );
    }
    }
    }
    =================================

    Is there a way to do that using a simple php-code from Credit Tracker?

    Thank you very much for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author labs64

    (@labs64)

    Hello @phoenixsa07,

    Yes, you can do this using standard Worpress shortcode call from the code:

    <?php echo do_shortcode( '[caption id="'.get_post_thumbnail_id( $post->ID ).'"]<p>%author%</p>[/caption]' ); ?>

    Best, Labs64

    • This reply was modified 6 years, 4 months ago by labs64.
    Thread Starter phoenixsa07

    (@phoenixsa07)

    Hi,
    thank you so much for your quick reply!
    I tried it with this code, but unfortunately a white page with an error message appears …. Can it be related to the fact that I use a Genesis Theme? or is not your code so easy to install in my above?

    Thank you!!!

    Plugin Author labs64

    (@labs64)

    Hi @phoenixsa07,

    Actually, the theme shouldn’t be an issue in this case.
    May I ask you to provide exact error message from the webpage or possible from the log as well.

    Thread Starter phoenixsa07

    (@phoenixsa07)

    Hi!

    I have inserted your code in mine:

    //* Add featured image on single post
    add_action( 'genesis_entry_content', 'maker_featured_image', 1 );
    function maker_featured_image() {
    
    	$add_single_image = get_theme_mod( 'maker_single_image_setting', true );
    
    	$image = genesis_get_image( array(
    			'format'  => 'html',
    			'size'    => 'featured-image-large',
    			'context' => '',
    			'attr'    => array ( 'alt' => the_title_attribute( 'echo=0' ), 'class' => 'aligncenter' ),
    		) );
    
    	if ( is_singular() && ( true === $add_single_image ) ) {
    		if ( $image ) {
    			printf( '<div class="featured-image">%s<div class="featured-image-credits">'<?php echo do_shortcode( '[caption id="'.get_post_thumbnail_id( $post->ID ).'"]<p>%author%</p>[/caption]' ); ?>'</div></div>', $image ); 
    		}
    	}
    }

    then the following message appears:

    Parse error: syntax error, unexpected ‘?’ in /www/htdocs/w00a8160/gesundheitsrebell_de/wp-content/themes/maker-pro/functions.php on line 281

    Plugin Author labs64

    (@labs64)

    Sorry, my bad – hab’ printf nicht gesehen 😉

    Please replace your printf with this

    printf( do_shortcode( '[caption id="'.get_post_thumbnail_id( $post->ID ).'"]%s[/caption]' ) , $image );

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP code to display Copyright manually’ is closed to new replies.