WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] All posts from all categories (12 posts)

  1. kakilo
    Member
    Posted 10 months ago #

    Hi guys,
    Appreciate for reading this.

    We all know that when we click on a category the page lists all posts from that category you've clicked. Okay.

    Turns out that I need something to show all posts from all categories.

    Is there anyway to do that WITHOUT creating a master category and giving it to all posts in the blog?

    Thanks in advance,
    Henry.

  2. Ryan Love
    Member
    Posted 10 months ago #

    Hi Henry,

    I need something to show all posts from all categories

    That's what a blog does?

    It lists all your posts from all your categories.

    Ryan

  3. kakilo
    Member
    Posted 10 months ago #

    But it must be a specific page and show EVERYTHING, since the beginning.
    I think it's more likely to a page template.

    Thanks.

  4. Ryan Love
    Member
    Posted 10 months ago #

    Yup, the blog can do that.

  5. kakilo
    Member
    Posted 10 months ago #

    How can I set the sorting method to alphabetically in that case?

    Really appreciate your help. I'll try that.

  6. Ryan Love
    Member
    Posted 10 months ago #

    And this is where we hit my limits!!

    Unfortunately I wouldn't know how to sort it alphabetically or if this is even possible. Hopefully someone else will be able to assist you with this part.

  7. kakilo
    Member
    Posted 10 months ago #

    I think it is possible. Reading the documentation I've found a query to sort posts but appears it isn't working or I must be doing something wrong.

    I edited category.php and post-loop.php with this:

    $wp_query->set( 'orderby', 'title' );
    $wp_query->set( 'order', 'ASC' )

    Thanks in advance.

  8. shadez
    Member
    Posted 10 months ago #

    why not use get_recent_posts?

    check link and examples:
    http://codex.wordpress.org/Function_Reference/wp_get_recent_posts

  9. esmi
    Forum Moderator
    Posted 10 months ago #

  10. kakilo
    Member
    Posted 10 months ago #

    I'm using a custom template on posts.
    I'm getting the post custom field and not an excerpt, for example.

    I need a page to list these posts in that template (I could duplicate it if it's necessary) and show up to the user in alphabetical order.

    Can I use a page template for that?

    Thxx

    Using get_recent_posts it will lists all posts?
    Can I use sort by title?

  11. shadez
    Member
    Posted 10 months ago #

    u mean custom post types? or custom page style?

    as asmi suggested check 'pre_get_posts'.
    dump this code in your functions.php file to list all posts everywhere in asc order:

    function asc_query_order( $query ) {
            $query->set( 'orderby', 'title' );
            $query->set( 'order', 'ASC' );
        }
        add_action( 'pre_get_posts', 'asc_query_order' );

    you can put an if statement right at the beginning of the function to check for categories or post types etc as need be...

  12. kakilo
    Member
    Posted 10 months ago #

    Hi guys!

    My needs was to use a custom field to show in that page. I've solved my purpose using get_recent_posts. See the code below:

    <?php
    	$args = array( 'numberposts' => '5', 'orderby' => 'post_date', 'order' => 'ASC', 'tax_query' => array(
    			array(
    				'taxonomy' => 'post_format',
    				'field' => 'slug',
    				'terms' => 'post-format-aside',
    				'operator' => 'NOT IN'
    			),
    			array(
    				'taxonomy' => 'post_format',
    				'field' => 'slug',
    				'terms' => 'post-format-image',
     				'operator' => 'NOT IN'
    			)
    	) );
    	$recent_posts = wp_get_recent_posts( $args );
    	foreach( $recent_posts as $recent ){
    echo '<li class="clearp" style="list-style: none; margin: 0;"><strong><a>' .   $recent["post_title"].'</a></strong>  ';
    echo do_shortcode(get_post_meta($recent["ID"], 'Player de a├║dio', true)).'<a>Veja a letra</a>';
    
    	}
    ?>

    Thanks for everyone!
    Gratefully,
    Henry.

Reply

You must log in to post.

About this Topic