WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Feeds and Displaying them (10 posts)

  1. Cregy
    Member
    Posted 8 years ago #

    Hi Guys

    I don't even know what to look for so I hope someone can point me in the right direction please!

    http://www.weddingcompanycornwall.co.uk/

    On the above site I have two wp installations for designers and tips. What I would like to do is to take a feed from the tips area. I would like to take the categories feed and use it for the front page and also randomly select a tip and place in a box. A sort of teaser type thing.

    Can anybody tell me how I might do this please?

    Thanks

    Rich

  2. maerk
    Member
    Posted 8 years ago #

    Actually, it sounds like you might do better learning how to use the Loop for what you want to do.

    The Loop is what WordPress uses to display posts, and you can read about it on the codex:

    http://codex.wordpress.org/The_Loop

    You can use it on any PHP page you like, it doesn't have to be a WordPress page.

  3. Cregy
    Member
    Posted 8 years ago #

    Hi

    I have read the loop pages and I am a little bit confused. How do I get the loop to display categories from a different directory please?

    I have the main front page as root and then tips as /tips/ and designers as /designers/! If I want to pull a list of categories from tips how do I tell the loop to go to the tips directory to get the list of categories please?

    Is it something to do with either of these please:
    <?php define('WP_USE_THEMES', false); get_header(); ?>
    <?php wp_head(); ?>

    Thanks

    Rich

  4. maerk
    Member
    Posted 8 years ago #

    Just before starting the loop you would put an include for the relevant wp-blog-header.php file. That way you link to correct wordpress installation.

  5. Cregy
    Member
    Posted 8 years ago #

    Hi

    I have ended up with something like this:
    '<?php require('http://www.weddingcompanycornwall.co.uk/tips/wp-blog-header.php'); ?>'
    '<h2>Tips</h2>'
    '

      '
      '<?php wp_list_cats('sort_column=name&optioncount=1'); ?>'
      '

    '
    but it doesn't work!

    Any ideas why please?

    Thanks

    Rich

  6. maerk
    Member
    Posted 8 years ago #

    What actually happens when you try the code above?

    It might be that you're using a URL, sometimes that doesn't work (some hosts disable that feature for security reasons).

    Try a relative reference, like:

    <?php require('tips/wp-blog-header.php'); ?>

    That way, PHP knows you are calling a file within the internal file system, and not something over the internet.

    Actually, I've just thought, since you're putting that in a theme file, you'll need to modfify the path. This one below might do the trick:

    <?php require('../../../tips/wp-blog-header.php'); ?>

  7. Cregy
    Member
    Posted 8 years ago #

    Hi Maerk

    You're a beauty! Spot on with your first call. Changed the url to a . and take a look:
    http://www.weddingcompanycornwall.co.uk/
    Works brilliantly!

    Now I have a list of categories, I just need to work out how to do a random post!

    Thanks

    Rich

  8. Cregy
    Member
    Posted 8 years ago #

    Hi All

    I got the random post thing to work by applying the advice from Kafkaesqui at:
    http://wordpress.org/support/topic/40818?replies=14

    Now all I have to do is to get it to respond to some css and also only display a part of the tip - not the whole lot!

    Thanks for all the help

    Rich

  9. maerk
    Member
    Posted 8 years ago #

    Random post... that's a bit more tricky. If wordpress has a ready-made argument that you can pass, so much the better, but if not you might have to work something out yourself. It shouldn't be too hard, actually, I'll take a look at it when I get back home.

  10. maerk
    Member
    Posted 8 years ago #

    Yeah, I was just going to suggest that method.

    To get it to display only part of the tip, you can use the_excerpt(); instead of the_content();.

    More about the_excerpt();:

    http://codex.wordpress.org/Template_tags/the_excerpt

Topic Closed

This topic has been closed to new replies.

About this Topic