Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show Post on top


  • wlaurito
    Participant

    @wlaurito

    Hi!
    Is it possible to bring the last commented post to the top of the activity stream again?

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

  • wlaurito
    Participant

    @wlaurito

    Someone?


    zimou13
    Participant

    @zimou13

    This solution is based on some code by Justin Tadlock. pre_get_posts is called before WordPress gets the posts of the main loop. Basically, you test to see if the page is the archive of the post type and make sure post_parent hasn’t been set. Then you set post_parent to 0, which is the default parent of top level posts. Easy as pie.
    <?php
    //pre_get_posts filter is called before WordPress gets posts
    add_filter( ‘pre_get_posts’, ‘my_get_posts’ );

    function my_get_posts( $query ) {
    //if page is an archive and post_parent is not set and post_type is the post type in question
    if ( is_archive() && false == $query->query_vars[‘post_parent’] && $query->query_vars[‘post_type’] == ‘my_post_type’)
    //set post_parent to 0, which is the default post_parent for top level posts
    $query->set( ‘post_parent’, 0 );
    return $query;
    }
    ?>
    see: https://showbox.onl/, https://vidmate.onl/ & https://mobdro.onl/


    sajeerAP
    Participant

    @sajeerap

    As i am well with wordpress self hosted mechanism, in the knowledge of me, to shop post on top, we want to make the stick on top option that are shown in the beneath of the publish button. I also wrote one article regarding this couple of years ago.

    Thanks
    shajeer
    https://sajeetech.com/

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar