How to show full post by clicking the read all button?

1

I'm creating a blog and would like to know how to do the following:

On the home page I display the title, an image and a summary of the post, and clicking the "Read All" button opens the post completely in another browser window, such as in internet blogs.

I've been developing as follows: I've done the entire layout of a website for a business in my city, more exactly a building materials store, and a news portal was also requested.

I'm just running tests on an external project, before incorporating it into the site code. I'll post the code so you can see. I'm very lay with PHP, I'm using Notepad ++ to develop my code.

<?php require( 'conectar.php') ?>
<!doctype html>
<html>

    <head>
        <meta charset="utf-8">
        <title>Blog</title>
    </head>

    <body>
        <?php $sql=m ysql_query( " SELECT * FROM postagem ORDER BY data DESC"); $conta=m ysql_num_rows($sql); if($conta <=0 ){ echo '<h2>Nenhuma postagem encontrada.</h2>'; }else{ while($res=m ysql_fetch_array($sql)){ ?>
        <div class="postagem"> <span> <h2><a><?php echo $res['titulo']; ?></a></h2> </span>  <span> <h3><a><?php echo $res['postagem']; ?></a></h3> </span> 
        </div>
        <?php }} ?>
    </body>

</html>

I found the following function.:

function new_excerpt_more($more) {
global $post;
return ‘… <a href=”‘. get_permalink($post->ID) . ‘”>’ . ‘Ler matéria completa &raquo;’ . ‘</a>’;
}
add_filter(‘excerpt_more’, ‘new_excerpt_more’);

Would I be able to apply it to my need?

    
asked by anonymous 02.06.2014 / 19:39

1 answer

1

I do not know the structure of your project, but I'll try to explain.

You have a page where you display all posts, on this page, in the title of each post as in your code, you have added a link that can lead to another page, passing as a parameter the id of the post that should be displayed , example:

 <div class="postagem"> <span> 
  <h2>
     <a href="lerPostagem.php?id=<?php echo $res['id'];?>" title="ler postagem completa">
        <?php echo $res['titulo']; ?>
     </a>
  </h2> 

On the readPosition.php page, you should get the parameter id via GET and select the post in your Database:

$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM postagem WHERE postagem.id = $id");

With the post selected you can view it completely on this page.

Note: Care needs to be taken to avoid SQL , consider using prepare statements with PDO or Mysqli .

Note 2: This is just a didactic explanation, there are N ways to do it, you would need to know your project better to advise you better.     

02.06.2014 / 21:40