• Resolved bsean23

    (@bsean23)


    Hey,

    I had a custom WordPress theme designed and they used a gallery plugin for my homepage. I want to get rid of the gallery plugin because I only want to use one static image on the homepage. No need for a gallery/slider plugin.

    So here is my code right now…

    <?php  if ( is_front_page() ) include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php');
    			else
    			{
    			 while ( have_posts() ) : the_post(); ?>

    Now again, I just want to have a static image on the homepage. So I thought the code would be something like this:

    <?php  if ( is_front_page() ) include ('<img src="IMG URL HERE">');
    			else
    			{
    			 while ( have_posts() ) : the_post(); ?>

    That doesn’t work though. I’m sure there must be something wrong with that. And I’m sure there is a simple way to fix this, but I don’t know PHP really.

    Can anyone help me out here? I’m sure it’s a simple coding error, so if someone here who knows PHP well can post the correct code I would really appreciate it.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Firstly please, copy the output on of gallery.
    Secondly, traverse to the level of img tag in markup.
    thirdly, replace src of img tag with required one.
    fourthly, replace <img src=”IMG URL HERE”> with html obtained from above.
    lastly, replace include with echo ??

    Thread Starter bsean23

    (@bsean23)

    Hey limexs… I’m sorry but I don’t quite understand your post. I’m looking to just take the first block of code above and instead of having the ‘ABSATH ./wp-content/plugins/’ section, just have it so a static image is displayed using the “img src” HTML code.

    ?? Sorry if it was difficult to interpret

    you can use following

    <?php
     if ( is_front_page() ) {
      echo '<img src="path/to/image" />';
     }
     else
     {
      while ( have_posts() ) : the_post();
     }
    ?>
    Thread Starter bsean23

    (@bsean23)

    limexs, when I apply that code I get the following:

    Parse error: syntax error, unexpected '}' in /home/domain/public_html/wp-content/themes/mytheme/page.php on line 27

    Thread Starter bsean23

    (@bsean23)

    limexs, thanks for posting that. All I did was remove the last ‘}’ on the code you posted and it worked fine. You rock! Thanks so much!

    ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Removing gallery, replacing with static images (simple PHP code? few seconds…)’ is closed to new replies.