• Hi All

    Back to some Beginner coding after years away, I have a static website with a wordpress blog as a subdirectory, /blog.
    I have successfully managed to pull the latest posts to my static front page.
    https://www.seenovascotia.com/wpposts2.php ( test Page)
    My site is all about travel and photographs, so I’d like to pull the photo that goes with each post, with the post. I’ve tried a few examples but either it’s not working or only pulling the photo for one post. Can any one suggest a line that would add the photo that’s posted and size it to 300px.

    Here is the code I am currently working on, Needs some style still.

    Cheers Mike H

    <?php query_posts( ‘showposts=6’ );
    while ( have_posts() ) : the_post();
    ?><h4 class=”home link”>“target=”_blank”><?php
    the_title(); ?>
    </h4><?php
    the_post_thumbnail();
    the_excerpt();
    endwhile; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @mikehhfx,
    You can just modify some lines in your code above.

    <?php query_posts( ‘showposts=6’ );
    while ( have_posts() ) : the_post();
    ?><h4 class=”home link”>“target=”_blank”><?php
    the_title(); ?></h4>
    <?php if ( has_post_thumbnail() ) {
    set_post_thumbnail_size(‘300px’, ‘300px’);
    the_post_thumbnail();
    }
    the_excerpt();
    endwhile;
    ?>

    You can set the size of the featured image you wish to have.

    Hope it serves you as required.
    Thanks!

    Hello,

    You just need to replace

    
    the_post_thumbnail();
    

    With

    
    the_post_thumbnail( 'medium' );
    

    The medium size defaults to 300×300 pixels (unless you changed them in Settings > Media).

    Hope that helps.

    Thread Starter mikehhfx

    (@mikehhfx)

    Hi Folks

    Thanks for the info, but when I add this to the code, The page does not load. Here is the original page above loads fine. Here is the new page with added code.
    I get an “HTTP 500 Internal server error” – https://www.seenovascotia.com/wpposts3.php

    Thanks for any help

    Here is the full page code

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="https://www.w3.org/1999/xhtml">
    <head>
    <?php require('blog/wp-blog-header.php');
     
     
     /*if you are getting 404 errors uncomment the next 2 lines*/
    status_header(200);
    nocache_headers();
     
    ?>
    <script type="text/javascript"> 
      var feedurl = "https://seenovascotia.com/blog/feed/";   // the full url to your blogs feed xml file  usually   yourblogaddress.com/feed/
      var feedbackcolor = "white";    // ie  white  green  yellow  etc or any Color Name found at https://www.w3schools.com/colors/colors_hex.asp
      var feedscrollspeed = "2";      // specify number from  1 - 5  larger number = faster scroll speed
      var feedwidth = "296px";        // width of feed scroller in pixels
      var feedheight = "500px";       // height of feed scroller in pixels
    </script>
    
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="https://www.affiliateswitchblade.com/affiliateswitchblade_files/scrolllatestposts.js"></script>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SeeNovaScotia.com</title>
    <meta name="google-site-verification" content="1s5SNVwH0GtkPw9g6oXxbivYkIhYZjpYOyMsC1vAlME" />
    
    <meta name="verify-v1" content="aYF198ocxe7U1Y5ROVJRRirk6ZEF83FsgzOgFAvnLFU=">
    <meta name="description" content="Spend your vacation in Nova Scotia. SeeNovaScotia.com for all your travel information and see what Nova Scotia has to offer, from the City of Halifax to Cape Breton Island. ">
    <meta name="keywords" content="nova scotia,halifax,atlantic canada,fishing,hunting,birdwatching,swimming,lunenburg,chester,beaches,camping,tartan,fiddle,keltic,highlands,scottish,louisburg,louisbourg,whalewatching,fossils,world heritage,dartmouth,twin cities,city of trees,yarmouth,ocean,playground">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    
    <style type="text/css">
    <!--
    .style1 {
    	color: #666600
    }
    -->
    </style>
    </head>
    
    <body>
    <div align="center">
      <table width="900" border="1" cellspacing="3" cellpadding="3">
        <tr>
          <td colspan="2"><p><img src="graphics/banners/seeNovaScotiabevelbkground.jpg" alt="SeeNovaScotiaBanner" width="936" height="144" /></p>
          <p><img src="graphics/menus/SeeNSMenu2011.jpg" alt="SeeNSMenu" width="936" height="36" /></p></td>
        </tr>
        <tr>
          <td height="134" colspan="2"><div align="center">
          <!-- START EMBED CODE -->
    
    <script type="text/javascript" src="https://mikeharvey.ca/ssp_director/m/embed.js"></script>
    
    <div id="album-7"></div>
    
    <script type="text/javascript">
    	SlideShowPro({
    		attributes: {
    			id: "album-7",
    			width: 857,
    			height: 400
    		},
    		mobile: {
    			auto: false
    		},
    		params: {
    			bgcolor: "#000000",
    			allowfullscreen: true
    		},
    		flashvars: {
    			xmlFilePath: "https://mikeharvey.ca/ssp_director/images.php?album=7"
    		}
    	});
    </script>
    
    <!-- END EMBED CODE -->
          </div></td>
        </tr>
        <tr>
          <td height="134" colspan="2" class="style1"><div align="left">
            <p>&nbsp;</p>
            <p>Welcome to our web site, all about Nova Scotia. Our site is a photographic tour of Nova Scotia. You will see many wonderful places and attractions to help you plan your next vacation to Nova Scotia.. From the highlands of Cape Breton to the Annapolis Valley, vacationing in Nova Scotia is a thrilling experience. Walk on the bottom of the ocean at The Bay of Fundy or climb over the rocks at Peggy's Cove.Go swimmingin the ocean at one of our Ocean beaches or find a lake side secluded spot in the wilderness,it's all here for you to enjoy.<br />
              <br />
              Visit our Daytrips page where we provide you with photographs and information to help you find your way.<br />
              If you are a tourism business, you can advertise your business on our site. Or you can get a link from our site to yours.</p>
            <p>&nbsp;</p>
          </div></td>
        </tr>
        <tr>
          <td height="88" colspan="2"><div align="center">
            <div align="center">
              <script type="text/javascript"><!--
    
    google_ad_client = "pub-0927340454280874";
    
    /* SeeNovaScotia */
    
    google_ad_slot = "3516531596";
    
    google_ad_width = 728;
    
    google_ad_height = 90;
    
    //-->
    
            </script>
              
              <script type="text/javascript"
    
    src="https://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
            </div>      </tr>
        <tr>
        <td height="88" colspan="2">   
        <p align="center" class="style1">
              <iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLEA718AAF4D430EF5&hl=en_US" frameborder="0" allowfullscreen></iframe>
          </p> </tr>
        <tr>
        <td height="122" colspan="2" valign="top">
            <div align="center" class="style1"><p align="center"><font size="5"><a href="daytrips/index.htm">Google Map</a></font></p>
            <p align="center"><font color="#666600">This interactive Google map has place marks with photos of what 
              
            you will see at each place. </font></p></div>      </tr>
        <tr>
          <td width="624"><p align="center" class="style1 style4"><p align="center" class="style1 style4">Ryan Hull & The Storytellers</p>
            <p align="center" class="style1 style4"><img src="images/MH_RyanHull&Storytellers_WEB3047.jpg" alt="Ryan Hull" width="453" height="321" /></p>
            <p align="center" class="style1">Here are a some great songs by Nova Scotia artist Ryan Hull & The Storytellers</p>
          <p align="center" class="style1">. If you like his music follow the links and share or buy his music, support our local artists.</p>
          <p align="center" class="style1">
            <iframe style="border: 0; width: 400px; height: 241px;" src="https://bandcamp.com/EmbeddedPlayer/album=327093897/size=large/bgcol=ffffff/linkcol=0687f5/artwork=small/transparent=true/" seamless><a href="https://ryanhullandthestorytellers.bandcamp.com/album/this-road-ep">This Road EP by Ryan Hull and The Storytellers</a></iframe>
            ?</p>
          
          <div align="center">
            <div align="center">
            
            <!-- Go to www.addthis.com/dashboard to customize your tools -->
          </div>
          <div class="addthis_native_toolbox"></div>?</td>
          <td width="301" rowspan="3" valign="top">
            <p align="center" class="style1"><strong>Our latest blog posts</strong></p>
          
    <?php query_posts( ‘showposts=6’ );
    while ( have_posts() ) : the_post();
     ?><h5 class=”home link”>“target=”_blank”><?php
     the_title(); ?></h5>
     <?php if ( has_post_thumbnail() ) {
     set_post_thumbnail_size(‘300px’, ‘300px’);
    the_post_thumbnail();
     }
     the_excerpt();
     endwhile;
     ?>
    
            <p>&nbsp;</p>
            <p>
              
     </ul>
    
     &nbsp;
         
    
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
    </div>
    </body>
    </html>

    [Moderator note: Please do not post large chunks of code in messages. Use pastebin.com or gist.github.com and then paste a link to that here.]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘pulling photos with posts to static page’ is closed to new replies.