Skip to content

Instantly share code, notes, and snippets.

View douglasnev3s's full-sized avatar
🏠
Working from home

Douglas Ferreira Neves douglasnev3s

🏠
Working from home
View GitHub Profile
@douglasnev3s
douglasnev3s / command
Created December 21, 2018 00:20 — forked from argentinaluiz/command
cmder no PHPStorm, Pycharm, etc
"cmd.exe" /k set CMDER_ROOT=C:\cmder&&set ConEmuDir=%CMDER_ROOT%\vendor\conemu-maximus5&&call "%CMDER_ROOT%\vendor\init.bat"
@douglasnev3s
douglasnev3s / gitBash_windows.md
Created April 3, 2018 12:39 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows is bundled with "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available. (Note: a portable alternative is Cmder, the full version comes bundled with Git Bash, notes here.)

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on). If you are missing a utility, such as wget, track down a binary for

function fib(n) {
if (n < 2) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
# LOOP
Uma das principais diferenças entre o WP_Query e o get_post(), é que no primeiro precisamos fazer um loop básico para buscar as informações que queremos de um determinado post. Com o get_post() não precisamos fazer loop, ele vai direto onde queremos.
Para o get_post() não importa se o que queremos é uma página ou um post, basta passar o ID e pronto, ele busca as informações necessárias. Já o WP_Query() precisa saber o que estamos buscando.
Quando usamos o WP_Query(), nós rodamos por default 4 queries no banco.
Uma query pega os dados da tabela de posts, outra pega os custom fields de uma meta table, a terceira query pega os dados do author da tabela de usuário e a quarta query pega os comentários relacionados ao post. Isso pode ser eficiente, mas só se você for usar todas essas informações. Nesse caso, elas já estarão prontas para serem consumidas.
Com o get_post(), usamos apenas uma query no banco. Ela geralmente usa a função setup_postdata() que permite usar templates tags como the_title(), isso