Referência própria do wordpress. Você encontra este artigo, mais bonito e organizado, e quem sabe até mais atualizado em: Para quem faz uso um pouco mais avançado do WordPress, especialmente quem trabalha desenvolvendo sites com a plataforma, é bem comum aparecerem situações um tanto complexas. Para estas questões, seguem 13 fantásticos comandos SQL para WordPress! Uma maneira prática de executar comandos SQL é através do phpMyAdmin. Até a hospedagem mais básica dá acesso à ferramenta de banco de dados, então não há dificuldades nisso. Os comandos SQL para WordPress a seguir são para o prefixo padrão do WordPress “wp_”. 1. WordPress armazena o caminho absoluto da URL do site (“siteurl”) e URL da home (“homeurl”) no banco de dados.
UPDATE wp_options SET option_value = REPLACE(option_value, ' ' WHERE option_name = 'home' OR option_name = 'siteurl'; 2. 3. 4. 6. 7. 8. 9. 11. 12. 13. Curtir isso: Function Reference/query posts. Languages: English • Italiano • 日本語 • 中文(简体) • Português do Brasil • (Add your language) Description Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query.
It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like making use of pre_get_posts hook, for this purpose. query_posts() is a way to alter the main query that WordPress uses to display posts. It does this by putting the main query to one side, and replacing it with a new query. It should be noted that using this to replace the main query on a page can increase page loading times, in worst case scenarios more than doubling the amount of work needed or more. Caveats Usage.
Class Reference/WP Query. Languages: English • Italiano • 한국어 • 日本語 • 中文(简体) • Português do Brasil • (Add your language) Description WP_Query is a class defined in wp-includes/class-wp-query.php that deals with the intricacies of a post's (or page's) request to a WordPress blog. The wp-blog-header.php (or the WP class in Version 2.0) gives the $wp_query object information defining the current request, and then $wp_query determines what type of query it's dealing with (possibly a category archive, dated archive, feed, or search), and fetches the requested posts. It retains a lot of information on the request, which can be pulled at a later date. Interacting with WP_Query Most of the time you can find the information you want without actually dealing with the class internals and global variables. There are two main scenarios you might want to use WP_Query in.
The second is during The Loop. Usage Standard Loop <? Standard Loop (Alternate) <? Multiple Loops If you have multiple queries, you need to perform multiple loops. How to Display Featured Posts with Thumbnails in WordPress. Rockin’ out WordPress custom loops — kristarella.com. What’s a loop? When using WordPress, “The Loop” refers to the code in your template files that displays posts. Usually there is only one main loop per page, but you can have secondary custom loops to show special content. These can include recent posts and related posts. The loop depends on queries A query is related to the loop in that it determines what should be shown in the loop. Default and custom queries The main query for a WordPress page is determined automatically by the type of page you are viewing (it’s all handled by WordPress).
Global $query_string; query_posts($query_string . The above code gathers the variable $query_string, which contains all the default query information and then uses query_posts() to create a query with all of the features of the default query, except the attributes that you change. The benefit of using $query_string in this way is that you don’t destroy page pagination on the home and archive pages, which will happen when using query_posts() by itself.