dta38159 2014-05-12 06:50
浏览 18
已采纳

在wordpress中的帖子之间切换

I have created a sidebar.php-file with the code;

<section class="sidomeny"><p class="Senastenytt2"><?php get_search_form();?></p></section><!--Slut på sidomeny-->

<div id="nyhet3">

  <?php

    query_posts('category = all');

    if (have_posts()) :

       while (have_posts()) : ?>

             <?php the_post(); ?>

         <p class="datum2"><?php the_time('Y-m-d'); ?></p>
         <p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>

     <?php the_excerpt(); ?>
          <p class="textnyhet2"></p>


      <?php 
        endwhile;
        endif;
      ?>

</div><!--Slut på Nyhet3-->

And now I would like to add the function that if you press the sidebar news section, the "textnyhet2" section will get updated with the news you clicked on. That is how it's working now.

But the problem is that the sidebar vanished whenever you click on one of those "latest news" links. So what I need help with is to edit the sidebar.php-file so the "latest news" function with links is still there so you don't have to go back one page whenever you would like to read about another post.

Im not sure how to do this. If it's php involved or if you can do it by simple visiting the posts/pages section in wordpress.

Would be grateful if anyone could help me. If I have forgotten any necassary information please tell me and I will the post.

Thanks!

<?php
get_header();
?>
<section class="textinnehall">
<?php
if (have_posts()) :
   while (have_posts()) :
      the_post();
      the_content();
   endwhile;
endif;?>
</section>
<section class="sidomeny">
<?php
get_sidebar(); ?>
</section>
<?php
get_footer(); 
?>

This is my page.php file. Don't know if it will be to any help. But the sidebar is already active.

  • 写回答

1条回答 默认 最新

  • du21064 2014-05-12 08:15
    关注

    May be the sidebar is not called in your single page.

    you need to have the same design in your themes single.php page(As per twenty ten theme standard).

    <p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>
    

    The href <?php the_permalink() ?> takes the post to single page for full view

    Just call the sidebar in your theme's single page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题