• i am using below code that seems to work fine on my local server but when i use it live server , it just displays first page content on every page .

    content does not changes on moving to next page while , pagination index show currnet page index though.

    below is my code :

    <?php
    /*
    Template Name: My News
    */
    get_header();

    // First, let’s see if we have the data in the cache already
    $the_query = wp_cache_get(‘m-in-news’); // the cache key is a unique identifier for this data

    if ($the_query == false) {
    // Looks like the cache didn’t have our data
    // Let’s generate the query
    $args = array(
    ‘posts_per_page’ => 10,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘pdf_cin_file’,
    ‘compare’ => ‘!=’,
    ‘value’ => ”,
    ),
    ),
    ‘orderby’ => ‘post_date’,
    ‘paged’ => $paged,
    ‘order’ => ‘DESC’,
    ‘post_type’ => ‘minnews’,
    ‘post_status’ => ‘publish’,
    ‘cache_results’ => true
    );
    $the_query = new WP_Query($args);

    // Now, let’s save the data to the cache
    // In this case, we’re telling the cache to expire the data after 300 seconds
    wp_cache_set(‘m-in-news’, $the_query, ”, 300); // the third parameter is $group, which can be useful if you’re looking to group related cached values together
    }

    $max_page = $the_query->max_num_pages;
    $big = 999999999;
    ?>
    <div class=”master”>
    <?php get_sidebar(‘presslistpages’); ?>
    <div class=”rightSection”>
    <h1><?php echo esc_html(get_the_title()); ?></h1>
    <div class=”mNews”>
    <div class=”data_gird_content”>

      <?php
      // Once we’re here, the $query var will be set either from the cache or from manually generating the WP_Query object

      if ($the_query->have_posts()) {
      while ($the_query->have_posts()) {
      $the_query->the_post();
      $pdflink = get_post_meta(get_the_ID(), “pdf_cin_file”);
      $pdflink = isset($pdflink[0]) ? $pdflink[0] : ”;
      ?>

    • ” target=”_blank”><div class=”icon”><i class=”fa fa-angle-double-right”></i></div> <div class=”details”><h2><?php echo esc_html(get_the_title()); ?></h2></div>
    • <?php
      }
      }
      wp_reset_postdata();
      ?>
      </div>
      <div class=”paginationWrapper”><?php
      echo wp_kses(paginate_links(array(
      ‘base’ => str_replace($big, ‘%#%’, esc_url(get_pagenum_link($big))),
      ‘format’ => ‘?paged=%#%’,
      ‘current’ => max(1, get_query_var(‘paged’)),
      ‘total’ => $max_page
      )), array(‘a’ => array_merge(cci_allowed_a_tag_attr(), array(
      ‘href’ => array()
      )),));
      ?></div>
      </div>
      </div>
      </div>
      <?php
      get_footer();
      ?>

  • The topic ‘wp_cache_set not working as expected’ is closed to new replies.