Support » Fixing WordPress » Can this be done?

  • Hi,

    I want to try and show only the posts from wordpress on a php page. Taking the standard index.php found in the default theme folder I have made a copy and removed the header and footer and saved it as index2.php. I then made a page to include the index1.php file but it error’s. I’m guessing this have something to do with the way wordpress includes files.

    I used very simple code to include the file and was wondering if anyone else here had done anything like this before and if so, how did you do it?

Viewing 1 replies (of 1 total)
  • I use something like this for wordpress stuff to be displayed elsewhere on the domain (in this case, our blog is just used for news) – warning – it’s ugly.

    <?
     $sql="select * from wp_posts where post_status='publish' order by post_date desc limit 10";
     $res=mysql_query($sql);
     $no=mysql_num_rows($res);
     if($no>0){
     	while($rs=mysql_fetch_object($res)){
    					  ?>
     <a href="blog/?<? echo "p=".$rs->ID?>"> <? echo $rs->post_title?>&nbsp;&raquo;</a><br />
       <?
       		$strcontent=str_replace("Â","",$rs->post_content);
     		$strcon=strpos($rs->post_content,"<a");
     		if($strcon!=""){
     			if(strlen($strcontent)>200) {
     			$pos=strpos($strcontent," ",200);
     			$content= substr($strcontent,0,$pos);
     			}
     			else
     			$content= substr($strcontent,0,200);
     		}else{
     			if(strlen($strcontent)>130) {
     			$pos=strpos($strcontent," ",130);
     			$content= substr($strcontent,0,$pos);
     			}
     			else
     			$content= substr($strcontent,0,130);
     		}
     ?>
       <? //echo $content;?>
     <?
     	}
      }else{
     ?>
     <p><strong>No News items posted!!</strong><br /> </p>
     <?
      }
     ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Can this be done?’ is closed to new replies.