T
T
tsi3amttaf2018-06-04 23:44:35
WordPress
tsi3amttaf, 2018-06-04 23:44:35

Can't output a string in a function, what's wrong?

Please poke your nose into the guide.
The result of this function is not what I imagined it to be.
This is how it [function] should work: But in fact, this is what happens: Here is the function itself:
<meta content="http://domain.com/image.jpg"/>
http://domain.com/image.jpg<meta content=""/>

function meta_image() {

  $default_img = is_singular() && has_post_thumbnail() ? the_post_thumbnail_url() : get_theme_mod( 'ktps_image_uploader_output' );
  echo '<meta content="' . $default_img . '" />';
  
}
add_action( 'wp_head', 'meta_image' );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniel Tsioma, 2018-06-05
@tsi3amttaf

$default_img = is_singular() && has_post_thumbnail() ? the_post_thumbnail_url() : get_theme_mod( 'ktps_image_uploader_output' );

On this line , replace
get_the_post_thumbnail_url()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question