WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] several "recent entries", is it possible? (14 posts)

  1. europasobreruedas
    Member
    Posted 6 years ago #

    My blog is related to the import of cars Audi, BMW, Mercedes and Porsche from Germany to Spain. I would like to have in my blog:
    -- Audi last entry
    -- Bmw Last entry
    -- Mercedes last entry
    -- Porsche Last entry

    You know if can I do it?

    Thanks

  2. tsguitar
    Member
    Posted 6 years ago #

    So the different car manufacturers will be categories and you want to have the latest post from each category? Sure, that can be done:

    <?php query_posts('category_name=Audi&showposts=1');
    while (have_posts()) : the_post();
      // do whatever you want
    ?>
    <a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <?php
    endwhile;
    ?>

    That will give you a linked title of the latest entry in the Audi category. Just paste that loop as many times as you want, changing the category name as you need to.

  3. europasobreruedas
    Member
    Posted 6 years ago #

    Thanks tsguitar,

    So the different car manufacturers will be categories and you want to have the latest post from each category?

    Yes it is.

    What is the file that I modify, single.php?
    I did:

    <?php get_header();
       query_posts('category_name=Audi&showposts=1');
       if (have_posts()) : while (have_posts()) : the_post(); ?>
       ......

    Only I added the line

    <? php query_posts ( 'category_name = Audi & showposts = 1');

    but it doesn't work.
    Thanks

  4. tsguitar
    Member
    Posted 6 years ago #

    Where do you want all these entries to appear? In your sidebar? Edit sidebar.php. In the main blog area? Edit index.php.

    I'm not sure why you added the line you did. That query_posts is already in the original code I gave you. It's possible that doubling up on that line is what's causing things not to work. Tell me where you pasted that code and give me exactly what you pasted. Links to your blog would help, too.

    Do you have categories and entries in your blog yet? Do you have an entry in the Audi category? If so, the code I gave you will work.

  5. europasobreruedas
    Member
    Posted 6 years ago #

    Excuse me Tsguitar by confusion.
    My blog is: http://www.eruopasobreruedas.com/cronicas

    You can see "ÚLTIMAS IMPORTACIONES" and there are Mercedes cars mixed with Audi cars, Porsche cars, etc.

    Where do you want all these entries to appear? In your sidebar? Edit sidebar.php. In the main blog area? Edit index.php.

    I want it to appear in the sidebar on every page. Do you want send you the contents of sidebar.php, index.php, to tell me where do I have to integrate.

    Do you have categories and entries in your blog yet? Do you have an entry in the Audi category?

    Yes I have, in fact, if you go at the end the sidebar you can select "Audi" for example and you'll see three "Crónicas" then, if you look to the top de page you can see an error:

    WordPress database error: [Table 'europaso_cronicas.wp_categories' doesn't exist]
    SELECT cat_ID FROM wp_categories WHERE category_nicename = 'audi'

    Do you know solve it?

    Thank you for your patience

  6. tsguitar
    Member
    Posted 6 years ago #

    The link to your site is misspelled. This one should work:
    http://www.europasobreruedas.com/cronicas/

    If you paste the code I gave you in sidebar.php, toward the top, you should see the latest entry for Audi appear on every page that calls for sidebar.php. You'll need to experiment with pasting the code in different spots to see where it shows up on your final pages. Just get used to pasting, viewing your site to see where things appear, then deleting what you pasted, moving it somewhere else, and viewing your site again. You have too many things happening on your posts for me to dig through and figure out where to properly post things.

    As for the error that appears, it looks like your database is missing a table. I don't know what to tell you about that one, but it looks pretty serious. It's time to think about backing up your files and database (VERY important) and upgrading your copy of WordPress.

  7. tsguitar
    Member
    Posted 6 years ago #

    Found some info about the error you're running into:
    http://weblog.techdad.net/2007/09/25/blog-fix-hemingwayex-and-wordpress-23/
    http://wordpress.org/support/topic/135540?replies=41
    http://wordpress.org/support/topic/135636?replies=6

    That should give you some reading and some solutions. Best of luck.

  8. europasobreruedas
    Member
    Posted 6 years ago #

    Thanks tsguitar for information about error, that's working now.

    I pasted your code in sidebar.php and don't working, looks sidebar.php code

    <div id="back">
        <?php if (isset($_SERVER["HTTP_REFERER"])) { ?>
            <span>&laquo; <a href="<?php echo $_SERVER['HTTP_REFERER'];?>" title="Volver en Cr&oacute;nicas">Volver</a></span>
        <?php } ?>
            <a href="#documentContent" title="Subir en Cr&oacute;nicas">Subir</a> &raquo;
        </div>
    </div>
    </div>
    <div id="column2">
    <div class="container-left">
    <div class="rss"><a href="<?php bloginfo('rss2_url'); ?>" title="Subscribirse a <?php bloginfo('name'); ?>" class="iconrss">Suscripci&oacute;n a RSS de CR&Oacute;NICAS</a></div>
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Left Sidebar') ) : else : ?>
        <ul><li class="listHeader"><h2><?php _e('Calendar'); ?></h2></li>
            <li class="calendar"><?php get_newcalendar() ?></li>
        </ul>
        <ul><li class="listHeader"><h2><?php _e('Archives'); ?></h2></li>
            <?php wp_get_archives('type=monthly'); ?>
        </ul>
        <ul><li class="listHeader"><h2><?php _e('Categories'); ?></h2></li>
            <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=0'); ?>
        </ul>
    <?php endif; ?>
    </div>
    </div>
    </div>

    I'm going to experiment with pasting the code in different spots. For example, I pasted your code in single.php

    <?php get_header(); ?>
    <?php query_posts('category_name=Audi&showposts=1'); ?>
    <?php query_posts('name=Audi&showposts=1'); ?>
    
       <? if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">

    and don't working, maybe because isn't "category_name" else "name", but I have the error: "Sorry, no posts matched your criteria.".

    Thanks and I'll continue check.

    That's right, address is http://www.europasobreruedas.com/cronicas, excuse me.

  9. tsguitar
    Member
    Posted 6 years ago #

    I don't know if the second query_posts line you have in there is messing things up. category_name is the term to use. I tested the code I gave you in a version of WordPress that's older than yours and it worked fine. Try posting the whole thing in the sidebar (don't try to change anything at all):

    <?php query_posts('category_name=Audi&showposts=1');
    while (have_posts()) : the_post();
      // do whatever you want
    ?>
    <a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <?php
    endwhile;
    ?>
  10. europasobreruedas
    Member
    Posted 6 years ago #

    Ok tsguitar,
    I pasted your code in sidebar.php, in fact I left it pasted because I think it does nothing. You can see sidebar.php with new code:

    <?php query_posts('category_name=Audi&showposts=1');
    while (have_posts()) : the_post();
      // do whatever you want
    ?>
    <a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <?php
    endwhile;
    ?>
       <div id="back">
        <?php if (isset($_SERVER["HTTP_REFERER"])) { ?>
            <span>&laquo; <a href="<?php echo $_SERVER['HTTP_REFERER'];?>" title="Volver en Cr&oacute;nicas">Volver</a></span>
        <?php } ?>
            <a href="#documentContent" title="Subir en Cr&oacute;nicas">Subir</a> &raquo;
        </div>
    </div>
    </div>

    I don't understand anything, maybe need to paste the code in another file, what do you think?. I'll follow with tests. Thanks.

  11. europasobreruedas
    Member
    Posted 6 years ago #

    Eureka,
    I already know where the code is added, at the end of the page. Look this páge: http://www.europasobreruedas.com/cronicas/importacion-porsche-911-carrera-russelsheim-alemania/

    I'll leave it until you see, I don't know why he added there and not in the sidebar. By the way, instead of 1 post I white 4 in line:

    <?php query_posts('category_name=Audi&showposts=4');

    Are you the true reason why the added post at the end rather than sidebar?

    Thanks

  12. europasobreruedas
    Member
    Posted 6 years ago #

    Sorry, I published twice the same post

  13. tsguitar
    Member
    Posted 6 years ago #

    The links show up at the bottom of the page because your sidebar.php code requires that they show up there. You have that query_posts bit running inside your column1 DIV; your sidebar is all inside the column2 DIV. Look at the source of the page and you'll see what's going on and why it shows up at the bottom of the page. You'll need to edit your template to solve that problem and that should be another thread from this one. This thread was all about showing the latest few posts from different categories and it looks like that's solved, right?

  14. europasobreruedas
    Member
    Posted 6 years ago #

    ok, that's right. Thank you very much.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags