dimanche 31 mai 2015

combine sprintf with IF condition

I'm stuck with a stupid problem. I was asked to arrange some changes in a php website template. So here is the code for the header/hyperlink:

<?php the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>

And this should be combined with:

<?php if( in_category('local-msr') ) { echo 'target="_blank" '; } ?>

I have tried something like this:

<?php the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark" if( in_category('local-msr') ), echo 'target="_blank">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>

But without succes.

Any ideas on how to make this work? Thanks!

Aucun commentaire:

Enregistrer un commentaire