Herramientas de usuario

Herramientas del sitio


wiki2:wordpress

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:wordpress [2015/01/03 20:30]
alfred [How to...]
wiki2:wordpress [2020/05/09 09:25] (actual)
Línea 251: Línea 251:
  
 === Get all posts === === Get all posts ===
-Using the argument post_status:​+Using the argument post_status=any and post_per_page=1:
 <code php> <code php>
 $args = array( $args = array(
Línea 258: Línea 258:
               '​order' ​    => '​ASC',​               '​order' ​    => '​ASC',​
               '​post_status'​ => '​any',​               '​post_status'​ => '​any',​
-              '​posts_per_page'​ => 10,+              '​posts_per_page'​ => -1,
             );             );
 $my_query = new WP_Query($args);​ $my_query = new WP_Query($args);​
 +</​code>​
 +
 +=== Get a concrete page content ===
 +<code php>
 +<?php $the_query = new WP_Query( '​pagename=contact'​ ); ?>
 +<?php while ( $the_query->​have_posts() ) : $the_query->​the_post();​ ?>
 +<​h2><?​php the_title();​ ?></​h2>​
 +<?php the_content();​ ?>
 +<?php endwhile; ?>
 +<?php wp_reset_postdata();​ ?>
 +</​code>​
 +
 +=== Get child pages from front page ===
 +First you must obtain the ID of the front page, it's stored in the wp_options WP table, as option_name=page_on_front and option_value=ID of the page. So if you want to retrieve this value, just use get_option('​page_on_front'​).
 +
 +<code php>
 +<?php $args = array(
 + '​child_of' ​    => get_option('​page_on_front'​),​
 + '​post_type' ​   => '​page',​
 + '​post_status' ​ => '​publish',​
 + '​title_li' ​    => '', ​
 +); ?>
 +<?php $children = wp_list_pages( $args ); ?>
 +<?php if ($children) : ?>
 +<ul>
 +<?php echo   ​$children;​ ?>
 +</ul>
 +<?php endif; ?>
 </​code>​ </​code>​
 ==== Other functionalities ==== ==== Other functionalities ====
wiki2/wordpress.1420317005.txt.gz · Última modificación: 2020/05/09 09:25 (editor externo)