Create Custom Page with Custom Loop and Query


Sponsored Links






Created WordPress as CMS? I am guarantee you’ll need this tricks. Because WordPress Custom Page is Gregorius tools we can use to create custom design/layout and whatever we want. I will show you how to Create Custom Page with Custom Loop and Query in WordPress and we’ll put some custom query (added extra query) to create custom loop as like in front page.

Create Custom Page with Custom Loop and Query

How To Create Custom Page with Custom Loop and Query

Example we want to put on Custom Loop content only from special category such as Tricks category. So all articles category will be loaded in our custom page example WordPress Tricks pages. Let’s move on.

We need to duplicate your default page.php template and rename it to page-tricks.php and added extra line on top header.

<?php
/*
Template Name: Page WordPress Tricks
*/
?>

And we need added extra loop or remove default query. Whatever you want, I keep my original query and added extra query to create new loop. Here’s what I do. After original loop, I write some code below

<?php  $temp_query = $wp_query; ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$sticky=get_option('sticky_posts');
$args=array(
   'caller_get_posts'=>1,
   'category_name' => 'Tricks',
   'post__not_in' => $sticky,
   'paged'=>$paged,
   'posts_per_page'=>6,
   );
//query_posts($args);
$my_query = new WP_Query($args);

while ($my_query->have_posts()) : $my_query->the_post();
?>
<div class="post-theme post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

				<div class="entry">
					<p><?php the_excerpt(); ?></p>
				</div>   

<div class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> <?php if(function_exists('echo_tptn_post_count')) echo_tptn_post_count(); ?></div>

<div class="clear"></div>
   </div>
  <!-- Post -->
  <?php endwhile; ?>
<br class="clear" />
  <?php if(function_exists('wp_pagenavi')) {  ?>
  <div class="navinavi">
    <?php
wp_pagenavi(); ?>
  </div>
  <br class="clear" />
  <?php } else { ?>
  <div class="navigation">
    <div class="alignleft">
      <?php next_posts_link(__('&larr; Previous Entries','public')) ?>
    </div>
    <div class="alignright">
      <?php previous_posts_link(__('Next Entries &rarr;','public')) ?>
    </div>
  </div>
  <?php } ?>
<?php
  $wp_query = $temp_query;
 wp_reset_query();
?>

And done, you can upload you page-tricks.php to your theme folder and create new page and choose WordPress Tricks page template and done. Now all content on our Tricks category will be show up on my WordPress Tricks page. If you got some problem, please let’s me know and I hope tutorial Create Custom Page with Custom Loop and Query useful for you

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net

How To Setup Multiple Loops in WordPress

WordPress built in with many query method, our example below about query is the best way to create Multiple Loops.  I will show you how to  do multiple loops in wordpress. let us assume we want to have two lists … Read More

How To Create “Dynamics Statics” Pages

There are so many WordPress Tricks that we can apply. In our current section we will show you, how to create "Dynamics" "Statics" Pages in WordPress. That's I mean on this point is simple. We will generated semi automatics pages … Read More

Custom Query String (Reloaded)

You can Download WordPress Plugin Custom Query String (Reloaded), this plugin is the perfect solutions to create and customize your WordPress Post. Custom Query String (CQS) provides a Admin Options panel whereby users may specify any number of custo

Create Post Pagination without Plugin

We are already now, there are wonderful plugin to create Post Pagination on WordPress that call WP Pagenavi. But today I will share it how to create Post Pagination without plugin without any plugin installed. This method only using litle … Read More

How To Create Custom Widgets

WordPress is the most Usable Publishing System I ever use and found, there are so many blogger and internet writer uses WordPress on they blog. WordPress has many free themes and plugins, the other reason is, they add nice featured … Read More

Automatically Create a Custom Field

WP Canyon did wonderful tricks, this tricks is about how to automatically create a custom field when a post is published. This wonderful method is added some code on your functions.php files on your current theme. The first time need … Read More

Create Custom Page with Custom Loop and Query / WordPress Tricks

Example we want to put on Custom Loop content only from special category such as Tricks category. So all articles category will be loaded in our custom page example read more

Source: http://wptricks.net/create-custom-page-with-custom-loop-and-query/

How to Create a Custom Post Types Archive Page in WordPress

Step by step guide on creating a custom post types archive page in WordPress. Create a custom page template, insert the query in your custom loop and you are done. read more

Source: http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-post-types-archive-page-in-wordpress/

WordPress: Create a Page Template that Paginates Posts from a

provides a custom theme developer is the simple ability to create custom page different use of query_posts() put before a normal loop vs contructing a new WP_Query read more

Source: http://www.tammyhartdesigns.com/wordpress/wordpress-create-a-page-template-that-paginates-posts-from-a-certain-category/

How to Create a Page of Posts in WordPress | eHow.com

To do this, you need to first create a custom page template and then add code for a custom query that of code right after the end of the loop: read more

Source: http://www.ehow.com/how_8296005_create-posts-wordpress.html

Automatically Create a Custom Field / WordPress Tricks & Tips

Create Custom Page with Custom Loop and Query. Created WordPress as CMS? I am guarantee you’ll need this tricks. Because WordPress Custom Page is Gregorius tools we can read more

Source: http://wptricks.net/automatically-create-a-custom-field/


15 Responses to Create Custom Page with Custom Loop and Query

  1. Pingback: Tweets that mention How To Create Custom Page with Custom Query in WordPress # WordPress Tricks & Tips -- Topsy.com

  2. Pingback: Cara Membuat Custom Page Special / ID-JAUHARI

  3. Margarida Fernandes says:

    Hi, thanks for this tip. But can I link a search form to this page, so I search only in a specific category? If so how do I do that? I have been trying to create a search only in specific pages, and in the search form I have – action=”/pesquisar-criaturas”
    “pesquisar-criaturas” is the permalink for the page, using the template for my specific search. And the page is there if you go directly to that link, but if I make a search it gives me a 404 error.
    Can you give me any help with this?
    Thanks

    • WP Tricks says:

      HI Margarida Fernandes
      Can you explain more details? What’s you mean with link a search form? Of course you can add search form on this custom template. If you need searching method and display on some page… (with custom template) I think you need a little bit more complicated code or plugins..

  4. Margarida Fernandes says:

    if you go to criaturas.magaworks.com (still in development) there is a search form there, and it is supposed to search only in pages, not posts, so it only gives results of pages.
    So I created a new search page template “searchResults.php”, and added a new page “pesquisar-criaturas” using that “searchResults.php” as template. Then in my search form I added the code – action=”/pesquisar-criaturas”. But if I make a search it gives a 404 error. But if you go to the page “http://criaturas.magaworks.com/pesquisar-criaturas/” there is no error, the page is there.

    The code to search just pages is not implemented yet. Right now the “searchResults.php” has the same code has my search page, but it should work just the same right? Giving results for posts and pages.

    I just can’t figure out what is happening.

  5. Pingback: uberVU - social comments

  6. Pingback: How To Create "Dynamics Statics" Pages on WordPress # WordPress Tricks & Tips

  7. Pingback: How To Create “Dynamics Statics” Pages | Silver Blog

  8. Pingback: How To Create “Dynamics Statics” Pages | Unlock IMEI Cellphones

  9. Pingback: Custom Query String (Reloaded) | Unlock IMEI Cellphones

  10. Pingback: Automatically Create a Custom Field | Unlock IMEI Cellphones

  11. sheik says:

    if i create a page like page tricks, what is the file name of the page. and how to access this page. in the admin section i added my custom page in one menu.

    also, how to give link to access this page.

    suppose i want to access user custom page by clicking the link in another page, then how should i give the link to tag.

    Please explain more..

  12. Anawia says:

    how do I make a special page category. where now a category that we are open, that there is not a list of posts, but the list of categories that exist underneath. after we open again, there are new posts list.

    Thank you. please help

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>