Grow your CSS skills. Land your dream job.

Custom Query or ?

  • # February 1, 2012 at 1:17 pm

    I need to display archive post from a specific category with a specific tag and would like to be able to get the permalink to it. Is this possible?

    Any direction or suggestions is appreciate or If further explaining is needed.

    # February 1, 2012 at 1:21 pm

    Is this a specific post or a group of specific posts? If it’s a group, I would do something like this:
    < ?php query_posts('category=##&tag_id=##'); ?>
    Where ## is the id for your category and tag. Then I’d run the loop as normal. Make sure to use wp_reset_query after the loop.

    # February 1, 2012 at 1:36 pm

    It is a group and this will definitely get me started. Thanks. What if I want to link a string of text to this specific archive post group.

    basically, I have posts that belongs to a certain category and is tagged with a specific tag. I then have a page that has a link that needs to go to these post. Now, here is the catch.

    I have numerous pages. Each page has a a string of text that links to another specific tag and category. I was hoping to use archive.php or tag.php to display all of this and use the permalink to link the text within the page. I really dont want to create a new archive.php or tag.php for each custom query. This is probably confusing, but I could not figure out another way to break the site down.

    # February 1, 2012 at 1:43 pm

    Aaahhhh… Hmmmm. Off the top of my head I can’t see a different way to do it (other than custom templates per query).

    Well, there’s one way that you can do it with a single template, but I’m sure it’ll be the same amount of work, but maybe a little less.

    Let’s say you had 5 different queries that have their own page. You could create a new template, name-here.php, and in that template you’re going to have five different loops. You could say,

    < ?php
    if( is_page('##') {
    // do loop #1

    if( is_page('##') {
    // do loop #2

    // etc. ?>

    You’d have to select this template from the template drop down of each of the pages. Not the most flexible solution, but maybe something to get your brain churning on it.

    # February 1, 2012 at 1:46 pm

    Awesome. I did not even think of using is page.. Much obliged!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".