Viewing 15 replies - 16 through 30 (of 30 total)
  • Thread Starter zet_kr

    (@zet_kr)

    ??
    I promise to post another problem I’m having, in just a few minutes!

    Taken from e-sushi’s code, but UNTESTED, I think this will work for the left panel:

    <ul>
    <?php
       $mycategoryposts = get_posts('numberposts=-1&category=15');
       foreach($mycategoryposts as $post) {
    ?>
          <li><a href="<?php echo get_permalink() . '?myarticleid=' . $post->ID; ?>"><?php the_title(); ?></a></li>
       <?php } ?>
    </ul

    Then for the right panel:

    <?php
       if (isset($_GET['myarticleid'])) {
          $postid = $_GET['myarticleid'];
       } else {
          $postid = 55; // The default post to show
       }
       $lastposts = get_posts("p=$postid");
          foreach($lastposts as $post) {
             setup_postdata($post);
             the_title(); the_date();
    	     the_content();
          }
       }
    ?>

    If i could suggest one small change..

    $post = (int) $_GET['myarticleid'];

    or

    $post = intval( $_GET['myarticleid'] );

    If you’re expecting an integer..

    Thread Starter zet_kr

    (@zet_kr)

    Thank you very much! Most helpful!

    Thread Starter zet_kr

    (@zet_kr)

    exciting.
    I cant get the links open on the same page though, they keep opening on a “single” page…. hmm….
    https://zetterstrand.com/category/articles/

    I’m sorry. The left panel should get the permalink of the current page, not the permalink of the article.

    <ul>
    <?php
       $thispermalink = get_permalink();
       $mycategoryposts = get_posts('numberposts=-1&category=15');
       foreach($mycategoryposts as $post) {
    ?>
          <li><a href="<?php echo $thispermalink . '?myarticleid=' . $post->ID; ?>"><?php the_title(); ?></a></li>
       <?php } ?>
    </ul
    Thread Starter zet_kr

    (@zet_kr)

    ah!
    oh, but that does not work either…
    https://zetterstrand.com/category/articles/

    ??
    thanks for your efforts!

    Thread Starter zet_kr

    (@zet_kr)

    or should I save this template as ‘single.php’ so permalinks open in it?
    but that would defeat the purpose….hm….

    Do not save this as single.php – that will mess up other parts of the site.

    Why is the permalink for the left links like this:

    https://zetterstrand.com/2003/10/30/med-tydliga-forlagor/?myarticleid=293

    It should be the same as the one used to get to the page:

    https://zetterstrand.com/category/articles/?myarticleid=293

    Perhaps you need to get the permalink to the current page earlier in the template. Without seeing more of the actual code, it is hard to tell.

    Thread Starter zet_kr

    (@zet_kr)

    Thanks, I will try to find a way to insert the correct code.

    Meanwhile, I have made it work (!) by doing this tweak:

    In ‘single.php’ i put:

    <?php if ( in_category('15') ) { ?>
               //here i put all the code to make the category-15.php-page//
     <?php } else { ?>
               //here i put all the code to make the ordinary 'single.php'-page//
     <?php } ?>

    It’s not pretty. What do you think? should I keep it like this? ??

    I would not. Try hard-coding the link in the left panel to make sure it will work:

    <ul>
    <?php
       $thispermalink = 'https://zetterstrand.com/category/articles/';
       $mycategoryposts = get_posts('numberposts=-1&category=15');
       foreach($mycategoryposts as $post) {
    ?>
          <li><a href="<?php echo $thispermalink . '?myarticleid=' . $post->ID; ?>"><?php the_title(); ?></a></li>
       <?php } ?>
    </ul
    Thread Starter zet_kr

    (@zet_kr)

    Thanks! I’ll try that!

    Thread Starter zet_kr

    (@zet_kr)

    Beautiful!

    Glad it worked! Now, please use the dropdown at top right to mark this topic ‘Resolved’.

    Thread Starter zet_kr

    (@zet_kr)

    My sincerest thanks for all the help. That’s a wrap. I have a few other questions lining up, but i’ll take that in another thread.
    !!!Gracias!!!

Viewing 15 replies - 16 through 30 (of 30 total)
  • The topic ‘Is this design feasible?’ is closed to new replies.