WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Is this design feasible? (31 posts)

  1. zet_kr
    Member
    Posted 5 years ago #

    Is it possible to do this easily? (look at picture):
    http://dl.dropbox.com/u/3126472/wpdesign.jpg

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Depends what you mean by "easily". I'd suggest starting with Theme_Development

  3. zet_kr
    Member
    Posted 5 years ago #

    Thanks, I read abot themes, and ive made my own, im more wondering if where to find how to code this. is it possible to have links to posts that open in the same template but are not permalinks, for example?

  4. esmi
    Forum Moderator
    Posted 5 years ago #

    Sorry - not sure I follow. A link to any post within WP is a permalink, so what sort of links do you mean?

  5. MichaelH
    Member
    Posted 5 years ago #

    You might want to review Template Hierarchy and if you are saying you don't like a post's single view to be handled via single.php then look at several plugins that allow 'template specification per post'.

    http://wordpress.org/extend/plugins/single-post-template/
    http://wordpress.org/extend/plugins/custom-post-template/

  6. vtxyzzy
    Member
    Posted 5 years ago #

    Is something like this what you want?

    For the left panel, list your Article titles with the links pointing back to this page, but with an added parameter of the post ID of the article: http://mysite.com/articlespage/?myarticleid=44

    Then in the right panel, use $_GET['myarticleid'] to find the article to display in that panel.

  7. zet_kr
    Member
    Posted 5 years ago #

    Thank you all.
    esmi: The permalinks use the index page template (or if i get around to it, the 'single' template. I wanted the links to open in the same view in which the links are.

    MichaelH:Thanks for the links.

    vtxyzzy: That sounds exactly like how i would want it to work. (although I would like for the left panel links to show up there automatically as i post in that category, rather than having to manually write the links) Do you know of a place where I could see examples of such a code?

    I was thinking something like:
    In the left field:

    <?php
    
        $lastposts = get_posts('numberposts=1&category=15');
    
    foreach($lastposts as $post) {
        setup_postdata($post);
        the_date(ymd);  the_title(); the_meta();
    }
    ?>

    And then in the right field:

    <?php
           $lastposts = get_posts('numberposts=1&category=15');
    
    foreach($lastposts as $post) {
        setup_postdata($post);
        the_title(); the_date();
    	the_content();
    }
    
    ?>

    You can see the test code here, but only with one test post, and without linking, because i dont know how to do that:
    http://zetterstrand.com/media/

  8. e-sushi
    Member
    Posted 5 years ago #

    You're almost there!

    Remember... the sidebar links you want are like the permalink-titles of your posts. So you can use "almost the same code as in the content area".

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

    Use numberposts=-1 to list all posts in that category!

  9. zet_kr
    Member
    Posted 5 years ago #

    inserted that code, thanks (changed $mypostlink to $post, didnt work otherwise?)

    Now I get a list, with permalinks.
    But the permalinks open in another window (the index template - how to stop that?)

  10. e-sushi
    Member
    Posted 5 years ago #

    Create a template with the snippets you've got, then assign the template to the page you are trying to keep. The links should then pop up there.

    You'll need a plugin though... something about "templates for posts". Let me dig a bit!

  11. e-sushi
    Member
    Posted 5 years ago #

  12. zet_kr
    Member
    Posted 5 years ago #

    Thank you very much for your help

  13. e-sushi
    Member
    Posted 5 years ago #

    Always welcome! ;)

  14. Mark / t31os
    Moderator
    Posted 5 years ago #

    NOTE: showposts will become deprecated in time, and anything provided to that parameter is moved into posts_per_page field anyway, if you try to get into the habit of using posts_per_page in the same manner you do showposts then it'll save having to remember in the days to come.

    Appreciate the codex examples may not all necessarily reflect that, but some of those pages are old and require a few updates.

    Simply a FYI... :)

  15. zet_kr
    Member
    Posted 5 years ago #

    Good tip, I appreciate it.
    Cheers.

  16. Mark / t31os
    Moderator
    Posted 5 years ago #

    I should of been paying attention when i wrote that, i'm not sure posts per page applies to get posts, but the information is relevant for any query_posts or WP_Query call.

    My fault for being so eager to respond...

    Leason learned... :) At least until the next time.. :)

  17. zet_kr
    Member
    Posted 5 years ago #

    :)
    I promise to post another problem I'm having, in just a few minutes!

  18. vtxyzzy
    Member
    Posted 5 years ago #

    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();
          }
       }
    ?>
  19. Mark / t31os
    Moderator
    Posted 5 years ago #

    If i could suggest one small change..

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

    or

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

    If you're expecting an integer..

  20. zet_kr
    Member
    Posted 5 years ago #

    Thank you very much! Most helpful!

  21. zet_kr
    Member
    Posted 5 years ago #

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

  22. vtxyzzy
    Member
    Posted 5 years ago #

    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
  23. zet_kr
    Member
    Posted 5 years ago #

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

    :)
    thanks for your efforts!

  24. zet_kr
    Member
    Posted 5 years ago #

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

  25. vtxyzzy
    Member
    Posted 5 years ago #

    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:

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

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

    http://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.

  26. zet_kr
    Member
    Posted 5 years ago #

    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? :)

  27. vtxyzzy
    Member
    Posted 5 years ago #

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

    <ul>
    <?php
       $thispermalink = 'http://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
  28. zet_kr
    Member
    Posted 5 years ago #

    Thanks! I'll try that!

  29. zet_kr
    Member
    Posted 5 years ago #

    Beautiful!

  30. vtxyzzy
    Member
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.