PHP code example of whitefiredesign / wp-stick-posts-to-term

1. Go to this page and download the library: Download whitefiredesign/wp-stick-posts-to-term library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

whitefiredesign / wp-stick-posts-to-term example snippets


$sticky_query = StickyPost::query([taxonomy=string], [term=integer], [posts_per_page=integer]);

stdClass Object
    [query]     => WP_Query Object ## Use as the query for the loop
    [post_ids]  => Array ## The list of post ids that have been queried

$sticky_query = StickyPost::query('category', get_queried_object()->term_id, 2);
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'post__not_in' => $sticky_query->post_ids ) );
query_posts($args);

$sticky_query = StickyPost::query('topic', get_queried_object()->term_id, 2);

if ( $sticky_query->query->have_posts() ) {
    while ( $sticky_query->query->have_posts() ) {
    $sticky_query->query->the_post();

        // LoopdeLoop
                            
    }
}

$main_query = new WP_Query(array(
    // ...args galore
    'post__not_in' => $sticky_query->post_ids
));