• I am working on a site with a blog and several pages. Occasionally certain blog posts need to be dropped onto another page, kind of like an archive but only for certain posts and not inside month categories, they need to be listed by post title.

    Is there a good plugin to have WordPress grab posts with a specific tag and then have them put in an unordered list on another page?

Viewing 14 replies - 1 through 14 (of 14 total)
  • I don’t know about a plugin. Search the repository. But if I were doing this I’d lean toward adding a page to my template.

    Thread Starter christian_d

    (@christian_d)

    I am unfamiliar with PHP but I feel like I should learn it as it seems like I could just do a line like the one below (which archives all the posts by month) but set it so it grabs certain tags instead of everything. Does this seem feasible?

    <?php wp_get_archives('type=monthly') ?>

    What you want is query_posts() using a tag parameter.

    Thread Starter christian_d

    (@christian_d)

    Wow, thank you very much! You are a lifesaver!

    Thread Starter christian_d

    (@christian_d)

    I’m sorry, I’m having trouble with this. I created a tag “test” and then put this code in the page that I wanted the posts with that tag to appear but nothing happened: `<?php query_posts(‘tag=test’) ?>’

    Sorry for these basic questions but I don’t even know which direction to go in.

    im having the same problem actually

    The semicolon is missing.
    And did you add it ahead of the loop?

    S.K

    Thread Starter christian_d

    (@christian_d)

    I tried it with the semicolon with the same result, should’ve mentioned that before. I’m sorry, I don’t know what the loop is, I’m new to this. I guess I’ll go learn about it and put this code before it. I put it in via the dashboard “pages” page with a PHP plugin. Should I be doing this another way?

    Copy the code of the “page” and paste in the pastebin: http://wordpress.pastebin.com/ and furnish the URL.

    S.K

    The Loop generally starts with this line: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>. Its the chunk of code that loops through all the posts that will be displayed on the page.

    I put it in via the dashboard “pages” page…

    You typed it into a page using the WP Post/Page Editor? That won’t work. PHP won’t execute if pasted into those panels. (The plugin Exec-PHP allows that though.) You need to be editing you page template directly.

    Thread Starter christian_d

    (@christian_d)

    Yea I used Exec-PHP to enter the code.

    Here is the code for my page.php file:
    http://wordpress.pastebin.com/f159fac31

    Here is the code for the specific page I’m trying to get this PHP to appear on:
    http://wordpress.pastebin.com/f34cbcbed

    Here is the URL to the page:
    http://jennifer.coffeeismagic.com/?page_id=6

    I have multiple WordPress pages on this site and I only want the script to run on one of them. — This is possible right?

    Thanks for all the help!

    Now that I think about it, I’m not sure that Exec-PHP will help you here. Someone who know Exec-PHP better than I can correct me if I’m wrong but if Exec-PHP runs code inside the posts, its running that code inside The Loop as well. You need to run this code before the loop begins. And to do that I think you’ll have to edit the php file.

    You need to put the query posts code above this line: <?php the_post() ?> but that line should really look like this: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> so that you loop through all of the posts returned and you’ll have to close the if statement and the while statement. If the if statement and the while statement are in your header file you are going to have to reorganize your theme or you’ll be running this code on every page of your site. Or create a new query object– something like this.

    @christian_d

    Ok. I was on a hiatus.

    Yes. As observed by our friends here, you can’t use Exec-PHP or any such plugin for the purpose of adding php lines of code to the templates. You have edit the template files yourself. In this case, you’ll have to add a line of code and also make any other change as necessary.

    If you want to know as to how to do it, give a shout.

    S.K

    Thread Starter christian_d

    (@christian_d)

    I’m still confused as to where the add the line of code. I don’t want these posts to appear on every page, just a single one. Where are the pages themselves in my directory? It seems like I’d need to edit a single page rather than the page template itself.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘How to list certain posts from a blog on another page.’ is closed to new replies.