Skip to content

Instantly share code, notes, and snippets.

@aldakur
Last active May 24, 2017 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldakur/de304a65579b7809dec46cd7cdbeba5d to your computer and use it in GitHub Desktop.
Save aldakur/de304a65579b7809dec46cd7cdbeba5d to your computer and use it in GitHub Desktop.
Wordpress tips
// BUCLE PARA POSTS
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
// Aqui codigo que se ejecutara cuando se encuentren articulos
<?php endwhile; else: ?>
// Aqui codigo que se ejecutara cunado no se encuentren articulos
<?php endif; ?>
// Para poder agregar plugins a nuestro tema es necesario las siguientes dos funciones.
// También hace que se vea la barra de arriba cuando estamos logeados en el blog
// header.php en el <head> antes de </head>
<?php wp_head(); ?>
// En el footer.php en el <body> antes de </body>
<?php wp_footer(); ?>
// Para mostrar solo contenido de una categoria. Antes de comenzar el bucle
<?php query_posts('category_name=nombre_de_la_categoria'); ?>
// SIDEBAR
// Para agregar Widgets. En mi Sidebar
// functions.php
register_sidebar(array (
'name' => 'Sidebar', // Inciamos el area del widget. En este caso el Sidebar del theme
'before_widget' => '<section class="widget">', // Doonde estara encerrado
'after_widget' => '</section>',
'before_title' => '<h3>', // El titulo
'after_title' => '</h3>',
));
// Para agregar Widgets. En mi Footer
register_sidebar(array (
'name' => 'Footer', // Inciamos el area del widget. En este caso el Sidebar del theme
'before_widget' => '<section class="widget">', // Doonde estara encerrado
'after_widget' => '</section>',
'before_title' => '<h3>', // El titulo
'after_title' => '</h3>',
));
// sidebar.php declararlo
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( 'Sidebar' ) ) : endif; ?>
// METODOS SIMPLES DE WORDPRESS
// Muestra solo el extracto del post
<div class="extract"><?php the_excerpt();?></div>
// Muestra todo el post
<div class="extract"><?php the_content();?></div>
// == PLUGINS == //
// get plugin name
$plugin = plugin_basename( __FILE__ );
// Create .pot file (terminal - Shell)
php wp-includes/makepot.php wp-plugin wp-content/plugins/MY_PLUGIN/ wp-content/plugins/MY_PLUGIN/languages/MY_PLUGIN.pot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment