General WordPress.org

Foro WordPress » WordPress » General WordPress.org

No funciona Entradas más antiguas en los posts por categorias (6 mensajes)

Acerca de este hilo

Tags

  1. broxs

    1.0
    Antiguedad: May 2011
    Mensajes: 3

    offline

    Publicado hace 1 año
    #

    Hola soy nuevo por aqui,un saludo para todos.

    Estoy creando un nuevo blog en el que he colocado esto:

    < ?php query_posts('category_name=apartamentos') ? >


    en una copia del index.php a la que he cambiado el nombre y le he colocado una llamada:
    < ?php
    /*
    Template Name: apartamentos
    */

    ? >


    y hasta aqui todo va bien, solo aparecen los post de la categoria apartamentos. El problema es que cuando pincho en entradas mas antiguas se abre la nueva pagina como pagina 2: ?page_id=247&paged=2 pero los post siguen siendo los de la pagina primera.En la pagina principal donde se utiliza index.php no ocurre el problema y pagina perfectamente.

    Os pido una ayudita con este problema y os envio un cordial saludo.

    El codigo completo es este:

    < ?php
    /*
    Template Name: apartamentos
    */

    ? >
    < ?php get_header(); ? >
    < style type="text/css" >
    < !--
    .Estilo2 {
        color: #4C4C4C;
        font-weight: bold;
        font-family: Verdana,"BitStream vera Sans",Helvetica,Sans-serif;
    }
    -- >
    < /style >

      < script type="text/javascript" >
    < !--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&amp;&amp;i< a.length&amp;&amp;(x=a[i])&amp;&amp;x.oSrc;i++) x.src=x.oSrc;
    }
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i< a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?")) >0&amp;&amp;parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&amp;&amp;d.all) x=d.all[n]; for (i=0;!x&amp;&amp;i< d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&amp;&amp;d.layers&amp;&amp;i< d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x &amp;&amp; d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i< (a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-- >
    < /script >
    < body >
    < ?php
        $options = get_option('inove_options');
        if (function_exists('wp_list_comments')) {
            add_filter('get_comments_number', 'comment_count', 0);
        }
    ? >
    < ?php if ($options['notice'] &amp;&amp; $options['notice_content']) : ? >
    < div class="post" id="notice" >
            < div class="content" >
                < ?php echo($options['notice_content']); ? >
                < div class="fixed" >< /div >
            < /div >
        < /div >
    < ?php endif; ? >
    < ?php query_posts('category_name=apartamentos') ? >
    < ?php if (have_posts()) : ? >
        < ?php while (have_posts()) : the_post(); update_post_caches($posts); ? >
            < div class="post" id="post-< ?php the_ID(); ? >" >
                < h2 ><a>" rel="bookmark" >< ?php the_title(); ? ></a>< /h2 >
                < div class="
    info" >
                    < div class="
    fixed" >< /div >
                < /div >
                < div class="
    content" >
                    < ?php the_content(__('Read more...', 'inove')); ? >
                    < div class="
    fixed" >< /div >
                < /div >
                        < /div >
        < ?php endwhile; ? >

    < ?php else : ? >
        < div class="
    errorbox" >
            < ?php _e('Sorry, no posts matched your criteria.', 'inove'); ? >
        < /div >
    < ?php endif; ? >

    < div id="
    pagenavi" >
        < ?php if(function_exists('wp_pagenavi')) : ? >
            < ?php wp_pagenavi() ? >
        < ?php else : ? >
            < span class="
    newer" >< ?php previous_posts_link(__('Siguientes', 'inove')); ? >< /span >
            < span class="
    older" >< ?php next_posts_link(__('Anteriores', 'inove')); ? >< /span >

                < ?php endif; ? >
      < div class="
    fixed" >< /div >
    < /div >

    < ?php get_footer(); ? >

  2. Avelino FV

    5.0
    Antiguedad: Jun 2009
    Mensajes: 101

    offline

    Publicado hace 1 año
    #

    Tendrás que indicarle tanto en previous posts como en next posts que sean los correspondientes a la categoria apartamentos en vez del genérico.
    Consulta el codex de WordPress aquí.

  3. Avelino FV

    5.0
    Antiguedad: Jun 2009
    Mensajes: 101

    offline

    Publicado hace 1 año
    #

    Puedes también probar instalando plugins como este.

  4. broxs

    1.0
    Antiguedad: May 2011
    Mensajes: 3

    offline

    Publicado hace 1 año
    #

    Gracias por tu respuesta, pero no he encontrado nada que me lo solucione. Mis conocimientos de php son muy limitados y no se muy bien donde hay que indicarle a previous posts y a next posts la categoria.

  5. Avelino FV

    5.0
    Antiguedad: Jun 2009
    Mensajes: 101

    offline

    Publicado hace 1 año
    #

    Gracias por tu respuesta, pero no he encontrado nada que me lo solucione. Mis conocimientos de php son muy limitados y no se muy bien donde hay que indicarle a previous posts y a next posts la categoria.

    Entiendo. Si no sabes programar resulta un tanto complejo.

    ¿Pero has probado el plugins que te indicaba en el post anterior? Concretamente: Post Category Only

  6. broxs

    1.0
    Antiguedad: May 2011
    Mensajes: 3

    offline

    Publicado hace 1 año
    #

    Al fin lo he solucionado, buscando por la web he encontrado este post del blog de anieto2K:
    http://www.anieto2k.com/2008/08/13/query_posts-y-el-problema-de-la-paginacion/

    Aunque he tenido que cambiar esto:

    < ?php if (have_posts()) : ? >
         < ?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                query_posts("category_name=apartamentos&amp;paged=$paged"); ? >
            < ?php while (have_posts()) : the_post(); ? >

    y ponerlo de este modo para que me funcione:

    < ?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                query_posts("category_name=apartamentos&amp;paged=$paged"); ? >
    < ?php if (have_posts()) : ? >
        < ?php while (have_posts()) : the_post(); update_post_caches($posts); ? >

    Gracias.

Responder

Debes Identificarte para publicar.

Foro WordPress » WordPress » General WordPress.org