Skip to content

Instantly share code, notes, and snippets.

@juanlopezdev
Last active August 2, 2019 17:24
Show Gist options
  • Save juanlopezdev/11c99f791f7cb339cdc5ca78a26fa2f6 to your computer and use it in GitHub Desktop.
Save juanlopezdev/11c99f791f7cb339cdc5ca78a26fa2f6 to your computer and use it in GitHub Desktop.
Funciones útiles para Wordpress

Obtener lista de tags. Referencia Codex

$tags_array = get_tags($args);

Obtener lista de tags de un post.

$post_tags = get_the_tags();
foreach ($post_tags as $tag) :
  $link = get_tag_link($tag->term_id);
  $name = $tag->name
endforeach;

Clase WP Query. Referencia Codex


Obtener detalle una categoría en un archivo category.php Referencia StackExchange

// category.php
$this_cat = get_category(get_query_var('cat'),false);

Habilitar Gutenberg cuando se registra un post personalizado. Referencia

// Agregar este parámetro en la función "register_post_type" 
(...)
'show_in_menu' => true
(...)

Navegar a un post anterior o siguiente del actual. Referencia

posts_nav_link(' || ', '< Anterior', 'Siguiente >');

Resultado:

<a href="#The_posts_nav_link">< Anterior</a> || <a href="#The_posts_nav_link">Siguient ></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment