WordPress.org

Forums

WP-PageNavi
All pages show the same posts (3 posts)

  1. FRANKMESA
    Member
    Posted 2 years ago #

    Please somebody can help me i'm getting crazy

    this is the website http://www.galanginternational.com/

    i just copied the pagenavi code inside "display posts shortcode " plug in .php

    and it show in the other pages the same posts!!
    code:

    // Create the shortcode
    add_shortcode( 'display-posts', 'be_display_posts_shortcode' );
    function be_display_posts_shortcode( $atts ) {
    
    	// Original Attributes, for filters
    	$original_atts = $atts;
    
    	// Pull in shortcode attributes and set defaults
    	$atts = shortcode_atts( array(
    		'author'          => '',
    		'category'        => '',
    		'date_format'     => '(n/j/Y)',
    		'id'              => false,
    		'image_size'      => false,
    		'include_content' => false,
    		'include_date'    => false,
    		'include_excerpt' => false,
    		'offset'          => 0,
    		'order'           => 'DESC',
    		'orderby'         => 'date',
    		'post_parent'     => false,
    		'post_status'     => 'publish',
    		'post_type'       => 'post',
    		'posts_per_page'  => '10',
    		'tag'             => '',
    		'tax_operator'    => 'IN',
    		'tax_term'        => false,
    		'taxonomy'        => false,
    		'wrapper'         => 'ul',
    	), $atts );
    
    	$author = sanitize_text_field( $atts['author'] );
    	$category = sanitize_text_field( $atts['category'] );
    	$date_format = sanitize_text_field( $atts['date_format'] );
    	$id = $atts['id']; // Sanitized later as an array of integers
    	$image_size = sanitize_key( $atts['image_size'] );
    	$include_content = (bool)$atts['include_content'];
    	$include_date = (bool)$atts['include_date'];
    	$include_excerpt = (bool)$atts['include_excerpt'];
    	$offset = intval( $atts['offset'] );
    	$order = sanitize_key( $atts['order'] );
    	$orderby = sanitize_key( $atts['orderby'] );
    	$post_parent = $atts['post_parent']; // Validated later, after check for 'current'
    	$post_status = $atts['post_status']; // Validated later as one of a few values
    	$post_type = sanitize_text_field( $atts['post_type'] );
    	$posts_per_page = intval( $atts['posts_per_page'] );
    	$tag = sanitize_text_field( $atts['tag'] );
    	$tax_operator = $atts['tax_operator']; // Validated later as one of a few values
    	$tax_term = sanitize_text_field( $atts['tax_term'] );
    	$taxonomy = sanitize_key( $atts['taxonomy'] );
    	$wrapper = sanitize_text_field( $atts['wrapper'] );
    
    // Set up initial query for post
    	$args = array(
    		'category_name'  => $category,
    		'order'          => $order,
    		'orderby'        => $orderby,
    		'post_type'      => explode( ',', $post_type ),
    		'posts_per_page' => $posts_per_page,
    		'tag'            => $tag,
                    'paged'          => $mypage
    
    	);

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. tady
    Member
    Posted 2 years ago #

    Hi there,

    I'm not really too sure what you are doing with the plugin, I assume you are trying to include it in the functions.php (or something like that).

    I found there are two things you need to do with a WP_Query custom query to make wp_pagenavi work. The first is you need to include ("paged" => $paged) in your arguments. The second is you need to pass your custom query to wp_pagenavi function like so:

    <?php wp_pagenavi(array( 'query' => $custom_query ));?>

    I'm not sure how you would apply this to your code above. The only thing I definitely CAN see from your code above is that the paged variable is pointed at $mypage, but $mypage doesn't appear to be initialised or setup anywhere. Maybe I'm just missing something...

    Hope that helps,

    T

  3. FRANKMESA
    Member
    Posted 2 years ago #

    i want pagenavi in the DISPLAYS POST SHORTCODE so i copied it in display-posts-shortcode.php (link :http://wordpress.org/support/topic/plugin-display-posts-shortcode-pagination?replies=15 )

    [large amount of code moderated - please use tha pastebin - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    ...i dont know why it doesnt work :( if you can help me, this is the website http://www.galanginternational.com and in the pages HOME,NEWS,DOWNLOADS i have DISPLAY POSTS SHORTOCODE plugin where inside i have PAGENAVI code so i can see it in all pages where i have DISPLAY POSTS SHORTCODE.
    THANKS

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic