How are texts and content in WordPress displayed from the PHP file? [closed]

2

I'm learning PHP to change the company's website, hosted on the server and already online. I have all the accesses, however I am only accustomed with HTML and CSS, and in the researches and beginner tutorials that I studied, they teach the normal programming syntax (variables, loops, etc), but I did not find anything that explained to me where the texts come from and content of the site in PHP. Here is a PHP code that returns the text:

  

We have a cd equipped with the best equipment of (...) stock and organization.

And the code for this seems to be this:

<div id="content">
            <?php wp_reset_query(); ?>
            <?php
            query_posts(
                    array(
                        'post_type' => 'logisticadinamica',
                        'orderby' => 'ID',
                        'posts_per_page' => 1
                    )
            );
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                    ?>  
                    <?php the_content(); ?> 
                    <?php
                }
            }
            ?>

I'm not asking you to teach me PHP because it would be absurd , I just want to know where the generated text is.

    
asked by anonymous 28.10.2015 / 12:59

1 answer

3

Everything within the opening and closing PHP tags ( <?php ?> ) will not appear in the HTML unless that the PHP command is print something.

Does not appear in HTML:

<?php $teste = "tal coisa"; ?>

Appears in HTML:

<?php echo $teste; ?>
Isto também aparece pois está fora das tags PHP.
<?php var_dump($teste); /* Este var_dump também aparece, mas este comentário PHP não aparece */ ?>

So the important thing is to know if the PHP command prints something or not. In a WordPress template you will find PHP-specific functions, such as echo and var_dump , and others specific to WordPress, type the_post and the_content .

While learning, always check these two sources to find out what a function does: the PHP manual and the WordPress manual.

The HTML of a WordPress site will be generated from the Theme / template files you have selected. Each theme file serves a specific situation, for example page.php will be used to show the content of the Pages (but not the Posts / Entries). Manual: WordPress> Template Hierarchy | Theme Developer Handbook | WordPress Developer Resources

    
28.10.2015 / 14:52