¡Esta es una revisión vieja del documento!
Core code files implement main Wordpress functions. /wp-includes/option.php, for example, contains functions for updating the site configuration, /wp-includes/pluggable.php and /wp-includes/ user.php contain function for updating users… Also exist /wp-includes/post.php, comments…
There is also the possibility to add more information to these elements (posts, users, comments…); to do that exists the concept of meta elements, which exists for other main elements in Wordpress.
wp-content\themes contains several folders, each one is an installed theme. You can develop your theme there.
WordPress themes only require two files: index.php and style.css. They usually are made up of many files and can become quickly disorganized. Still Wordpress does not need any folder you also can add a js and a css folders, in its root you'll place the template main files. There's also another especial folder, page-templates, where you will put the custom page template files.
So, to develop a theme you will create a folder with the name of the theme. There you will add an index.php file and a style.css.
WordPress uses the query string (a sequence of codes in a Uniform Resource Identifier (URI) that a web page uses to determine what dynamic data to display) to decide which template or set of templates should be used to display the page.
With the exception of the basic index.php template file, you can choose whether you want to implement a particular template file or not. If WordPress cannot find a template file with a matching name, it will skip to the next file in the hierarchy. If WordPress cannot find any matching template file, the theme’s index.php file will be used.
To add some logic to the template. The difference between functions.php and plugin.
A WordPress plugin:
A functions file:
In functions.php you can:
functions.php is loaded during theme setup, after any plugin files have loaded.
General uses for functions.php:
The style.css and the comment-reply script are required in all themes, but it may be necessary to add other files to extend the functionality of your theme. There are two steps to use scripts and styles in your template. First to register and second to enqueue it in the functions.php files.
// register a stylesheet and a script wp_register_style( $handle, $src, $deps, $ver, $media ); wp_register_script( $handle, $src, $deps, $ver, $in_footer ); // enqueue a style and a scriptt wp_enqueue_style( $handle ); wp_enqueue_script( $handle );
There are some of them already registered.
Rather then loading the stylesheet in your header.php file, you should load it in using wp_enqueue_style. In order to load your main stylesheet, simply insert:
wp_enqueue_style( 'style', get_stylesheet_uri() ); wp_enqueue_style( 'slider', get_template_directory_uri() . '/css/slider.css',false,'1.1','all'); wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), 1.1, true);
Special wordpress templates. They are only to change the look and feel of a page (not a post); they can be applied to a single page, a page section or a class of pages. page-about.php is a page template, more specific than page.php or index.php.
When a user requests a specific page, the core WordPress code decides which template to use for rendering that page. Template Hierarchy:
index.php — Or else WordPress uses the theme’s index file.
Name your template file so you can easily identify its template name, e.g., filename my-custom-page.php for the template name “My Custom Page.” Important! Do not use page- as a prefix, as WordPress will interpret the file as a specialized template, meant to apply to only one page on your site.
For example: Your About page has a slug of ‘about’ and an ID of 6. If your active theme’s folder has a file named page-about.php or page-6.php, then WordPress will automatically find and use that file to render the About page.
It's used to display posts according to your instructions given by template tags. The basic loop is (while there are posts, display the posts):
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
The most simple index.php would be:
<?php get_header(); if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; endif; get_sidebar(); get_footer(); ?>
Other example:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <?php endwhile; else: ?> <?php _e('Sorry, no posts matched your criteria.'); ?> <?php endif; ?>
WP_Query is a class given by WordPress to be used in the loop. For example $wp_query→have_posts() is called to see if there are any posts to show. To obtain a post $wp_query→the_post() is called. Also can be used to filter posts:
<?php $my_query = new WP_Query( $args ); ?> <?php while ($my_query->have_posts()) ? $my_query->the_post(); ?> // Do something <?php endwhile; ?>
They are used o control which templates are loaded on a certain page. Also which parts:
wp_head(), put it before </head> and wordpress will add required code for plugins.get_footer() includes the footer.php template file. get_header() includes the header.php template file. get_sidebar() includes the sidebar.php. Customized versions of these files can be called as well by naming the file sidebar-{your_custom_template}.php… You can then call the get_* functions with the custom template name as the only parameter, like this: get_header( 'your_custom_template' );.get_template_directory_uri(); & get_stylesheet_directory_uri();is_user_logged_in(), is_home(), is_front_page(), is_admin()…bloginfo('name'); to obtain information about the blog (name, title…)the_title();