Themes y Diseño

Foro WordPress » WordPress » Themes y Diseño

[Destacado] Queries, variables y códigos útiles para WordPress (35 mensajes)

Acerca de este hilo

Tags

  1. Sombrillita

    3.0
    Antiguedad: Mar 2009
    Mensajes: 44

    offline

    Publicado hace 3 años
    #

    Exelente,
    Estoy salvando en mi Favorito!
    Saludos XD

  2. dany

    2.0
    Antiguedad: Feb 2009
    Mensajes: 6

    offline

    Publicado hace 2 años
    #

    Este tuto me resulto super útil, gracias! Tengo una duda, al crear la página de categoría A para que muestre sólo los post de esa categoría se puede hacer que dichos post no aparezcan listados en el index o la página de archivos? O sea, que la página de categoría A sea totalmente independiente del resto.

  3. xanadu

    1.0
    Antiguedad: Ago 2009
    Mensajes: 4

    offline

    Publicado hace 2 años
    #

    Hola,me acabo de registrar porque es un foro bastante bueno, pero sobre todo para agradecer el trabajo de este tutorial tan bien explicado, y concreto. gracias

  4. emilsita

    2.0
    Antiguedad: Sep 2009
    Mensajes: 8

    offline

    Publicado hace 2 años
    #

    Hola, una consulta.. estoy tratando de q los posts correspondientes a una categoría se vean en una página aparte. Pero mi problema es que cuando busco en Atributos el menú desplegable para elegir la plantilla de página, no me da la opción. Sólo me deja elegir el orden en que se mostrarán las páginas.

    Alguien sabe donde está esta opción en wp 2.8? o necesitaré bajarme algún plugin?

    gracias!!

    PD: excelente tutorial...resulta sencillo hasta para mi que no entiendo nada de php.
    GRACIAS de nuevo

  5. analiavx

    5.0
    Antiguedad: Sep 2009
    Mensajes: 130

    offline

    Publicado hace 2 años
    #

    hola, quería saber si hay algún tutorial en video sobre eso de poner los post en una página diferente, es decir que aparezcan cada categoría en una página distinta de mi sitio, es que realmente no entiendo mucho, no porque lo expliques mal, sinó porque no soy buena para esto de los códigos y demás, soy muyyyy novata. Te agradecería una ayudita, porque mi sitio no tiene forma de nada y ya llevo 3 semanas tratando de hacer algo y no entiendo nada.

    Blogs: http://www.manejategratis.com.ar - wordpress 2.8.4 - Español.
    http://www.tusitionqn.com.ar - Wordpress 2.8.4 - Español.
  6. analiavx

    5.0
    Antiguedad: Sep 2009
    Mensajes: 130

    offline

    Publicado hace 2 años
    #

    Realmente soy muy bruta, necesito que me lo expliquen más para principiantes, sólo quiero que aparezcan los post en la categoría y la página que corresponden, porque todos me aparecen en la página principal.

    Blogs: http://www.manejategratis.com.ar - wordpress 2.8.4 - Español.
    http://www.tusitionqn.com.ar - Wordpress 2.8.4 - Español.
  7. GeoCON

    1.0
    Antiguedad: Ene 2010
    Mensajes: 3

    offline

    Publicado hace 2 años
    #

    Me párese excelente tu ayuda, solo que necesito un empujosito con este asunto. Yo estoy usando otro tema y creo que estos cambio los estas haciendo para el tema default, que viene con el WP pre-instalado.
    Yo estoy usando otro temita es el Station 1.2.0 por PageLines. Me podrían ayudar en este caso ya que no pude encontrar el código exacto del index donde copiar el query_post.

    Un Universo de Conocimiento
  8. GeoCON

    1.0
    Antiguedad: Ene 2010
    Mensajes: 3

    offline

    Publicado hace 2 años
    #

    Me párese excelente tu ayuda, solo que necesito un empujosito con este asunto. Yo estoy usando otro tema y creo que estos cambio los estas haciendo para el tema default, que viene con el WP pre-instalado.
    Yo estoy usando otro temita es el Station 1.2.0 por PageLines. Me podrían ayudar en este caso ya que no pude encontrar el código exacto del index donde copiar el query_post.

    Ya resolví el problemita. Para este tema de PageLines. Lo que se debe hacer es hacer simplemente un solo archivo de page.php y _pagecontent.php ya que el primero llama al segundo y también con el fin de no tener que hacer un archivo _pagecontent para cada pagina con categoría. Lo demás es igual.

    Un Universo de Conocimiento
  9. escael

    1.0
    Antiguedad: Mar 2010
    Mensajes: 3

    offline

    Publicado hace 2 años
    #

    que condicional debo usar para saber si un usuario esta logueado en mi sitio, esto es para mostrar u ocultar un formulario de logueo

    gracias de antemano

  10. Joel LM

    5.0
    Antiguedad: Dic 2008
    Mensajes: 290

    offline

    Publicado hace 1 año
    #

    Me ahorraste mucho tiempo.

    Gracias!

  11. Sabogal

    5.0
    Antiguedad: Dic 2008
    Mensajes: 254

    offline

    Publicado hace 1 año
    #

    Hace algún tiempo necesité que en las categorías nos e cargaran los último post sino que se cargaran aleatoriamente. Hoy cuando buscaba otra cosa, encontré la solución.

    Hay que agregar el siguiente código

    < ?php query_posts($query_string . '&amp;orderby=rand'); ? >

    Se agrega antes de

    < ?php if (have_posts()) : while (have_posts()) : the_post(); ? >

    Saludos!

  12. fliberty

    5.0
    Antiguedad: Oct 2009
    Mensajes: 1.511

    offline

    Publicado hace 1 año
    #

    Sabogal, Modificado un poco el orderby puedes ordenar los post por fecha, alfabéticamente, etc...

    En la web santuariochaman.com los ordeno de manera alfabética, pero para que funcione la paginación tendrás que colocarle &paged=$paged al final y mostrar post de categorías específicas si lo deseas.

    Visítenme:
    http://www.contigoperu.com.pe (hosting/dominios) | http://www.pachakamaq.com (temática variada) | http://www.mipycs.com (image hosting gratuito) | http://www.contigoperusemanario.org(noticias) | http://www.contigoperuclasificados.com (clasificados gratis) | http://www.cyberdocentes.com (recursos educativos)
  13. jeanbelmont

    1.0
    Antiguedad: Abr 2011
    Mensajes: 2

    offline

    Publicado hace 1 año
    #

    Hola primero deseo agradecer por el tuto que es muy completo, y segundamente deseo solicitar un poco de ayuda, apenas comienzo con esto de wordpress y php seguí todos los pasos para mostrar solo ciertas categorías en mis paginas con eso de la query, pero algo hice mal y no se que fue, la situación es que mi pagina se muestra con errores, todo el contenido lo muestra fuera del template aquí dejo 2 ejemplos primero el de mi código y luego de como se muestra en la pagina

    Edited:
    creo que por alguna razón no se muestran las imágenes que puse
    bueno aquí pondré el código como lo tengo a ver si alguien me puede decir que he echo mal

    < ?php
    /*
    Template Name: noticias
    */

    ? >

    < ?php
    /**
     * The main template file.
     *
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * E.g., it puts together the home page when no home.php file exists.
     * Learn more: <a href="http://codex.wordpress.org/Template_Hierarchy" rel="nofollow">http://codex.wordpress.org/Template_Hierarchy</a>
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */


    get_header(); ? >

            < div id="container" >
                < div id="content" role="main" >

                < ?php
                /* Run the loop to output the posts.
                 * If you want to overload this in a child theme then include a file
                 * called loop-index.php and that will be used instead.
                 */

                 get_template_part( 'loop', 'index' );
                ? >
                < /div >< !-- #content -- >
            < /div >< !-- #container -- >

    < ?php get_sidebar(); ? >
    < ?php get_footer(); ? >

    < ?php query_posts('category_name=noticias') ? >
     < ?php if ( have_posts() ) while ( have_posts() ) : the_post(); ? >

                    < div id="post-< ?php the_ID(); ? >" < ?php post_class(); ? > >
                        < ?php if ( is_front_page() ) { ? >
                            < h2 class="entry-title" >< ?php the_title(); ? >< /h2 >
                        < ?php } else { ? >
                            < h1 class="entry-title" >< ?php the_title(); ? >< /h1 >
                        < ?php } ? >

                        < div class="entry-content" >
                            < ?php the_content(); ? >
                            < ?php wp_link_pages( array( 'before' = > '< div class="page-link" >' . __( 'Pages:', 'twentyten' ), 'after' = > '< /div >' ) ); ? >
                            < ?php edit_post_link( __( 'Edit', 'twentyten' ), '< span class="edit-link" >', '< /span >' ); ? >
                        < /div >< !-- .entry-content -- >
                    < /div >< !-- #post-## -- >

                    < ?php comments_template( '', true ); ? >

    < ?php endwhile; // end of the loop. ? >

  14. LGrusin

    Moderador
    Antiguedad: Feb 2011
    Mensajes: 1.801

    offline

    Publicado hace 1 año
    #

    El código no se muestra correctamente con lo que no puedo saber si has hecho algo mal o es al ponerlo en el Foro.

    Por de pronto te puedo decir que no le pasas bien la categoría que quieres mostrar en el query.

    Crea un Hilo nuevo para esto y te seguimos allí.

    Un saludo

  15. jeanbelmont

    1.0
    Antiguedad: Abr 2011
    Mensajes: 2

    offline

    Publicado hace 1 año
    #

    Gracias LGrusin

    pues mira aquí con la noticia de que ya lo resolví, siguiendo los consejos aquí citados aunque de una manera un tanto mas sofisticada, sin embargo a mi parecer también mas fácil o mejor dicho flexible, pues al separar los códigos, pude tocarlos sin des componerlo todo el conjunto explico:

    hice 2 archivos el primero se llama noticias.php y es muy sencillo como un index primero llama a la cabecera luego llama al loop y finalmente sidebar y footer
    quedo asi:

    < ?php
    /*
    Template Name: noticias
    */

    ? >

    < ?php

    get_header(); ? >

            < div id="container" >
                < div id="content" role="main" >

                < ?php
                /* Run the loop to output the page.
                 * If you want to overload this in a child theme then include a file
                 * called loop-page.php and that will be used instead.
                 */

                get_template_part( 'loop', 'noticias' );
                ? >

                < /div >< !-- #content -- >
            < /div >< !-- #container -- >

    < ?php get_sidebar(); ? >
    < ?php get_footer(); ? >

    el segundo se llamo loop-noticias.php y es mas complejo pues quise insertar los plugins y todo eso que ya aparecia en la pagina de inicio, por lo cual me base en el loop-atachment.php y le hice solo 2 modificaciones, quedo asi:

    < ?php query_posts('category_noticias') ? >
    < ?php if ( have_posts() ) while ( have_posts() ) : the_post(); ? >

                    < ?php if ( ! empty( $post- >post_parent ) ) : ? >
                        < p class="page-title" ><a>post_parent ); ? >" title="< ?php esc_attr( printf( __( 'Return to %s', 'twentyten' ), get_the_title( $post- >post_parent ) ) ); ? >" rel="gallery" >< ?php
                            /* translators: %s - title of parent post */
                            printf( __( '< span class="
    meta-nav" >&larr;< /span > %s', 'twentyten' ), get_the_title( $post- >post_parent ) );
                        ? ></a>< /p >
                    < ?php endif; ? >

                    < div id="
    post-< ?php the_ID(); ? >" < ?php post_class(); ? > >
                        < h2 class="
    entry-title" >< ?php the_title(); ? >< /h2 >

                        < div class="
    entry-meta" >
                            < ?php
                                printf( __( '< span class="
    %1$s" >By< /span > %2$s', 'twentyten' ),
                                    'meta-prep meta-prep-author',
                                    sprintf( '< span class="
    author vcard" ><a href="%1$s" title="%2$s">%3$s</a>< /span >',
                                        get_author_posts_url( get_the_author_meta( 'ID' ) ),
                                        sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
                                        get_the_author()
                                    )
                                );
                            ? >
                            < span class="
    meta-sep" >|< /span >
                            < ?php
                                printf( __( '< span class="
    %1$s" >Published< /span > %2$s', 'twentyten' ),
                                    'meta-prep meta-prep-entry-date',
                                    sprintf( '< span class="
    entry-date" >< abbr class="published" title="%1$s" >%2$s< /abbr >< /span >',
                                        esc_attr( get_the_time() ),
                                        get_the_date()
                                    )
                                );
                                if ( wp_attachment_is_image() ) {
                                    echo ' < span class="
    meta-sep" >|< /span > ';
                                    $metadata = wp_get_attachment_metadata();
                                    printf( __( 'Full size is %s pixels', 'twentyten' ),
                                        sprintf( '<a href="
    %1$s" title="%2$s">%3$s &times; %4$s</a>',
                                            wp_get_attachment_url(),
                                            esc_attr( __( 'Link to full-size image', 'twentyten' ) ),
                                            $metadata['width'],
                                            $metadata['height']
                                        )
                                    );
                                }
                            ? >
                            < ?php edit_post_link( __( 'Edit', 'twentyten' ), '< span class="
    meta-sep" >|< /span > < span class="edit-link" >', '< /span >' ); ? >
                        < /div >< !-- .entry-meta -- >

                        < div class="
    entry-content" >
                            < div class="
    entry-attachment" >
    < ?php if ( wp_attachment_is_image() ) :
        $attachments = array_values( get_children( array( 'post_parent' = > $post- >post_parent, 'post_status' = > 'inherit', 'post_type' = > 'attachment', 'post_mime_type' = > 'image', 'order' = > 'ASC', 'orderby' = > 'menu_order ID' ) ) );
        foreach ( $attachments as $k = > $attachment ) {
            if ( $attachment- >ID == $post- >ID )
                break;
        }
        $k++;
        // If there is more than 1 image attachment in a gallery
        if ( count( $attachments ) > 1 ) {
            if ( isset( $attachments[ $k ] ) )
                // get the URL of the next image attachment
                $next_attachment_url = get_attachment_link( $attachments[ $k ]- >ID );
            else
                // or get the URL of the first image attachment
                $next_attachment_url = get_attachment_link( $attachments[ 0 ]- >ID );
        } else {
            // or, if there's only 1 image attachment, get the URL of the image
            $next_attachment_url = wp_get_attachment_url();
        }
    ? >
                            < p class="
    attachment" ><a>" title="< ?php echo esc_attr( get_the_title() ); ? >" rel="attachment" >< ?php
                                $attachment_width  = apply_filters( 'twentyten_attachment_size', 900 );
                                $attachment_height = apply_filters( 'twentyten_attachment_height', 900 );
                                echo wp_get_attachment_image( $post- >ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height.
                            ? ></a>< /p >

                            < div id="nav-below" class="navigation" >
                                < div class="nav-previous" >< ?php previous_image_link( false ); ? >< /div >
                                < div class="nav-next" >< ?php next_image_link( false ); ? >< /div >
                            < /div >< !-- #nav-below -- >
    < ?php else : ? >
                            <a>" title="< ?php echo esc_attr( get_the_title() ); ? >" rel="attachment" >< ?php echo basename( get_permalink() ); ? ></a>
    < ?php endif; ? >
                            < /div >< !-- .entry-attachment -- >
                            < div class="
    entry-caption" >< ?php if ( !empty( $post- >post_excerpt ) ) the_excerpt(); ? >< /div >

    < ?php the_content( __( 'Continue reading < span class="
    meta-nav" >&rarr;< /span >', 'twentyten' ) ); ? >
    < ?php wp_link_pages( array( 'before' = > '< div class="
    page-link" >' . __( 'Pages:', 'twentyten' ), 'after' = > '< /div >' ) ); ? >

                        < /div >< !-- .entry-content -- >

                        < div class="
    entry-utility" >
                            < ?php twentyten_posted_in(); ? >
                            < ?php edit_post_link( __( 'Edit', 'twentyten' ), ' < span class="
    edit-link" >', '< /span >' ); ? >
                        < /div >< !-- .entry-utility -- >
                    < /div >< !-- #post-## -- >

    < ?php comments_template(); ? >

    < ?php endwhile; // end of the loop. ? >

    ya por ultimo solo me gustaría quitar la entrada fija de bienvenida, para lo cual habría que mover (según yo) la parte de get_permalink, si me pudieran ayudar con ese ultimo detalle seria fantástico, desde ya muchas gracias por ayudar tanto a la comunidad sigan así

    blog.jeanbelmont.com

Responder

Debes Identificarte para publicar.

Foro WordPress » WordPress » Themes y Diseño