Hello, I don’t write PHP (yet) and would love someone to help me design a line or two.
I have posted a complete php page below for a Wordpress template.
By default the code causes any feature link to open in target=”_blank”
I would like to change the default to target=”_self” (this part I can do) but then I would like to make one link to an external site open using target=”_blank”
I am happy to add individual site urls for any exceptions to the default rule.
I have tried a few times to change myself but I am not experienced in PHP and don’t know the best way or correct code.
Let me know if you need any more, many thanks in advance - Lanx
<?php
/**
* The default template for displaying features entries
*
* @package WordPress
* @subpackage Bizz WPExplorer Theme
*/
//Vars
$wpex_feature_url = get_post_meta( get_the_ID(), 'wpex_feature_url', true ); ?>
<article id="id-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( $wpex_feature_url ) {
echo '<a href="'. $wpex_feature_url .'" title="'. get_the_title() .'" target="_blank" class="feature-entry-url clr">';
} ?>
<?php if ( get_post_meta( get_the_ID(), 'wpex_icon_font', true ) ) { ?>
<div class="feature-icon-font"><i class="fa fa-<?php echo get_post_meta( get_the_ID(), 'wpex_icon_font', true ); ?>"></i></div>
<?php } elseif ( has_post_thumbnail() && get_theme_mod( 'wpex_blog_post_thumb', '1' ) == '1' ) { ?>
<div class="feature-thumbnail">
<img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" />
</div><!-- .feature-thumbnail -->
<?php } ?>
<header class="feature-entry-header clr">
<h2 class="feature-entry-title"><?php the_title(); ?></h2>
</header>
<div class="feature-entry-content entry clr">
<?php the_content(); ?>
</div>
<?php if ( $wpex_feature_url ) {
echo '</a>';
} ?>
</article>