• person4659

    (@person4659)


    hi, when i click a link in my navigation; say for example gardening…i would like to show all posts from the gardening category. How can i make a separate query for a specific page only. i know you can get plugins which allow small amounts of code in the post, but it makes it a pig for styling and i use queries for the homepage…

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • vtxyzzy

    (@vtxyzzy)

    Perhaps the easiest way is to use the Page Links To plugin.

    The instructions are a little vague, but here is how to make it link to a category:

    1. Follow the installation instructions to install and activate the plugin.
    2. Edit the page you want to display a category.
    3. Scroll down to the ‘Page Links To’ section at the bottom.
    4. Click ‘An alternate URL’
    5. In the ‘Alternate URL’ box, enter ‘http://yoursiteurl/?cat=14’, replacing yoursiteurl with your own URL, and 14 with the category id you want that page to display.
    6. Click ‘Update Page’.

    That should be all you need.

    Thread Starter person4659

    (@person4659)

    thanks for that,its quite useful. i would like it to show the featured image which is connected to the posts…any idea how i would do that? this is why i wanted queries.

    vtxyzzy

    (@vtxyzzy)

    The exact answer to that depends on your theme. If you are using a free theme, post a link to your site here and someone may be able to help. If you are using a paid theme, we cannot examine its code or options, so you should contact the theme supplier.

    Thread Starter person4659

    (@person4659)

    nah its a skeleton theme which im coding myself…i dont have a live version atm; its only localhost.

    is there a way to modify this query which i have running for the homepage so that it will only show on a specific page. you have category = 6, so maybe you could add some sort of page = pagename

    <?php
    $args = array( 'numberposts' => 3, 'category' => 6 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    	<div class="rumour-posts">
        	<div class="rumour-posts-image">
           <?php the_post_thumbnail('post-image'); ?>
            </div>
        	<div class="rumour-posts-header">
            <h2><a>"><?php the_title(); ?></a></h2>
            </div>
    		<div class="rumour-posts-text"><?php the_content('Read More...'); ?></div>
    	</div>
        <div class="the-posts-line">
        	<hr />
        </div>
    <?php endforeach; ?>

    vtxyzzy

    (@vtxyzzy)

    Put the code in a template and assign the template to a Page. Then it will be used only on that Page.

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

The topic ‘making a query for a specific page’ is closed to new replies.