2 grammar corrections, tags edited, fluff removed as per https://meta.stackexchange.com/q/2950/295232
source | link

First at all thanks for helping. I´mI'm trying to make a theme that pickpicks an image from a folder based on the domain name, and if the file dodoes not exist, then place thea H3 with the site's title site.

My code is:

<?php $server_name = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']); $imagen = bloginfo('stylesheet_directory').'/images/logos/'.$server_name.'.png'; if (file_exists(get_template_directory(). '/images/logos/' .$server_name.'.png')) { ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php echo $imagen ?>" border="0" width="230px" height="60px" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

When I tested it on RESPONSIVE THEMEa responsive theme like:

 <?php if (file_exists(get_template_directory(). '/core/images/logos/'.$nombre_servidor = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']).'.png')){ ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

Itit works like a charm, but I cannot see what I´mI'm doing badwrong. May anyone give me a hand? Thanks!

First at all thanks for helping. I´m trying to make a theme that pick an image from a folder based on the domain name, and if the file do not exist, then place the H3 title site.

My code is:

<?php $server_name = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']); $imagen = bloginfo('stylesheet_directory').'/images/logos/'.$server_name.'.png'; if (file_exists(get_template_directory(). '/images/logos/' .$server_name.'.png')) { ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php echo $imagen ?>" border="0" width="230px" height="60px" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

When I tested it on RESPONSIVE THEME like:

 <?php if (file_exists(get_template_directory(). '/core/images/logos/'.$nombre_servidor = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']).'.png')){ ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

It works like a charm, but I cannot see what I´m doing bad. May anyone give me a hand? Thanks!

I'm trying to make a theme that picks an image from a folder based on the domain name, and if the file does not exist, then place a H3 with the site's title.

My code is:

<?php $server_name = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']); $imagen = bloginfo('stylesheet_directory').'/images/logos/'.$server_name.'.png'; if (file_exists(get_template_directory(). '/images/logos/' .$server_name.'.png')) { ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php echo $imagen ?>" border="0" width="230px" height="60px" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

When I tested it on a responsive theme like:

 <?php if (file_exists(get_template_directory(). '/core/images/logos/'.$nombre_servidor = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']).'.png')){ ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

it works like a charm, but I cannot see what I'm doing wrong.

    Post Migrated Here from stackoverflow.com
1
source | link

Wordpress Theme: replace logo image with title site if file doesn´t exist on server

First at all thanks for helping. I´m trying to make a theme that pick an image from a folder based on the domain name, and if the file do not exist, then place the H3 title site.

My code is:

<?php $server_name = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']); $imagen = bloginfo('stylesheet_directory').'/images/logos/'.$server_name.'.png'; if (file_exists(get_template_directory(). '/images/logos/' .$server_name.'.png')) { ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php echo $imagen ?>" border="0" width="230px" height="60px" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

When I tested it on RESPONSIVE THEME like:

 <?php if (file_exists(get_template_directory(). '/core/images/logos/'.$nombre_servidor = preg_replace('/([wW]{3,3}\.|)\.(es|com|net)/', '',$_SERVER['HTTP_HOST']).'.png')){ ?>
   <a href="<?php echo home_url( '/' ); ?>"><img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php bloginfo( 'name' ); ?>"/></a>
  <?php  }else{ ?>
<h3><?php bloginfo( 'name' ); ?></h3>
  <?php } ?>

It works like a charm, but I cannot see what I´m doing bad. May anyone give me a hand? Thanks!