How are Wordpress texts and content displayed from the PHP file?

Asked

Viewed 320 times

2

I am learning PHP to change the company website, hosted on the server and already online. I have all the access, but I’m used only to HTML and CSS, and in the beginner’s researches and tutorials I studied, they teach the normal programming syntax (variables, loops, etc), but I did not find anything to explain where the texts and contents of the site in PHP arise. Below is a PHP code that returns the text to me:

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

And the code for that seems to be that:

<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 would just like to know where the generated text is.

  • This is wordpress right there.

  • 1

    Exactly, which only makes my beginner life worse:’D

  • 4

    comes from wordpress, you can learn better here https://codex.wordpress.org/ this text is coming from the administrative area of the site try to access http://exemplo.com.br/wp-admin

  • Ah got it, logged in wordpress and found the texts there. So, for example, all the text below is only to add one of the menu tabs, in case you have any content, and if you have, I will find this content in wordpress and not in correct codes? <? php the_post_thumbnail('logisticaindex', array('title' => get_the_title())); ? > <H3>LOGISTICS</H3> <p> <?php abstract(20); ? > </p> <span><a href="<? php echo esc_url(home_url('/logistica/')); ? >">see more...</a></span> <?php

  • 1

    I’m sorry, I don’t mean to criticize, but how does a company get someone to change the site without having the slightest knowledge of the language? Just a suggestion, do not touch the native wordpress codes, because if you do this you will probably have a lot of headache. I’m sure you’ll take the comment as a constructive criticism.

1 answer

3


Everything within PHP opening and closing tags (<?php ?>) will not appear in HTML, except that the PHP command is for print out 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 specific PHP functions, like echo and var_dump, and other Wordpress specific, type the_post and the_content.

While learning, always refer to these two fonts to know 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 selected. Each Theme file serves a specific situation, for example the page.php will be used to display the contents of the Pages (but not the Posts/Entries). Manual: Wordpress Template Hierarchy | Theme Developer Handbook | Wordpress Developer Resources

Browser other questions tagged

You are not signed in. Login or sign up in order to post.