Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Dobrado

[Resolvido] Problemas com single.php

Recommended Posts

Estou tentando criar meu primeiro tema no wordpress, mas estou com problemas no Single.php.

O problema é:

Copiei o código do index, pro single.php. A única diferença é que retirei alguns div. Pois no index tem 3 div para os posts, cada um com sua categoria e divididos pelo loop:

<?php query_posts('category_name=coluna1&showposts=5'); ?>
. No index funciona muito bem.

 

Mas quando coloco o código no single.php (retirando o loop citado acima) ele mostra todos os posts do blog, ao invés de apenas um post.

 

Tentei retirar o loop, ele mostrou apenas 1 post, porém mostrou o post errado. Por exemplo, clico no post cuja a ID é 47 e ele mostra o post de ID 17 (isso acontece com qualquer post, apenas o 17 é mostrado.)

 

O código do single.php é esse:

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

<div id="content" align="center">		
<?php if (have_posts()) : ?>

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



<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>

<p><?php the_content(); ?></p>

<p class="info">Categorias: <?php the_category(' '); ?>. Postado em: <?php the_time('F jS, Y'); ?>





<?php endwhile; ?>

<div class="navigation clear">
			<div class="left"><?php next_posts_link('« Older Entries') ?></div>
			<div class="right"><?php previous_posts_link('Newer Entries »') ?></div>
		</div></div>


<?php else : ?>

	<h2 align="center">Not Found</h2>

	<p align="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>

			</div>
			
		</div>
<?php get_footer(); ?>
</body>
</html>

Se alguém puder me ajudar, agradeceria muito. Até mais, obrigado pela atenção.

Compartilhar este post


Link para o post
Compartilhar em outros sites

depois de

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

abra uma div assim..

<div class="post box" id="post-<?php the_ID(); ?>">

e fexe ela depois de:

<p class="info">Categorias: <?php the_category(' '); ?>. Postado em: <?php the_time('F jS, Y'); ?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Testei aqui.. tenta agora com esse..

Se der certo te conto onde tava o problema..^^

 

se não der, tem coisa errada ai.. rs..

 

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

<div id="content" align="center">   
            
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>


<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
</div>
<p><?php the_content(); ?></p>

<p class="info">Categorias: <?php the_category(' '); ?>. Postado em: <?php the_time('F jS, Y'); ?>





<?php endwhile; ?>

<div class="navigation clear">
                        <div class="left"><?php next_posts_link('« Older Entries') ?></div>
                        <div class="right"><?php previous_posts_link('Newer Entries »') ?></div>
                </div></div>


<?php else : ?>

        <h2 align="center">Not Found</h2>

        <p align="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>

                        </div>
                        
                </div>
<?php get_footer(); ?>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

É, não funcionou! hahaha

Eu realmente não sei o que pode ser... =S

Veja o blog, ta no meu dominio de testes: http://www.arteiros.co.cc/soundfactory/

Eu já usei códigos de outros templates nele, mas não funcionou... não sei o que pode ser!

Ah sim, pra começar eu usei o Startertheme (http://wpcandy.com/articles/the-wordpress-starter-theme-project.html) , pode ser isso?

 

Aqui tem do index, caso precise:

 

<?php get_header(); ?>

<?php get_sidebar(); ?>

  <div id="content"  align="center">
  

  <div id="left_side">

  <?php query_posts('category_name=coluna1&showposts=5'); ?>

  <?php if (have_posts()) : ?>

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



<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>

<p><?php the_content(); ?></p>

<p class="info">Categorias: <?php the_category(' '); ?>. Postado em: <?php the_time('F jS, Y'); ?>





<?php endwhile; ?>

<?php else : ?>

	<h2 align="center">Not Found</h2>

	<p align="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>

			</div>
			

			<div id="mainleft">

            <?php query_posts('category_name=coluna2&showposts=10'); ?>

  <?php if (have_posts()) : ?>

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



<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>

<p><?php the_content(); ?></p>

<p class="info">Categorias: <?php the_category(' '); ?>. Postado em: <?php the_time('F jS, Y'); ?>





<?php endwhile; ?>

<?php else : ?>

	<h2 align="center">Not Found</h2>

	<p align="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>
			</div>



			<div id="maincenter">

<?php query_posts('category_name=coluna3&showposts=10'); ?>

  <?php if (have_posts()) : ?>

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



<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>

<p><?php the_content(); ?></p>

<p class="info">Categorias: <?php the_category(' '); ?>. Postado em: <?php the_time('F jS, Y'); ?>





<?php endwhile; ?>

<?php else : ?>

	<h2 align="center">Not Found</h2>

	<p align="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>

			</div>

</div>


  <?php get_footer(); ?>

</body>

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu já usei códigos de outros templates nele, mas não funcionou... não sei o que pode ser!

como assim?

pode ser isso sim..

o ideal é fazer o seu template do zero ou personalizar um pronto..

Ficar unindo funções de vários pode dar problema...

=D

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu usei um framework, chamado startertheme e personalizei ele... E aconteceu isso.

As modificações que fiz foi remover o sidebar e adicionar o loop de categorias, basicamente. O resto foi só mudanças no CSS e adicionei alguns divs.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Desculpa, mas não achei o botão de editar tópico!

 

Por incrível que pareça resolvi o problema. Fui tirando tudo até achar o que tava errado... E era o Header! =S

usando o Feature Content ele simplesmente dava um erro no single.php.

Foi só retirar as linhas:

<div align="center" id="featurecontent">

	<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>

	</div>
E tudo voltou ao normal...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Viu o que da usar pedaços de temas prontos? hahaha.. rs..

Ok, tranquilo..

Abraços!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pior que essas foram as únicas partes que eu implementei sozinho! hahaha

 

Tentei com outro, o Wordpress Slide Posts (eu acho) e não funcinou.

 

Consegui fazer funcionar colocando o slide só no index. Porque se ele ficar no header o single.php não funciona de jeito nenhum. Não consegui descobri o porque.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.