Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter vedante30

    (@vedante30)

    I have found a ready to use solution for that issue (Till the PRO plugin will be fixed).
    Putting it here if anybody with same issue will need it.

    Add this code in your functions.php theme file:

    add_action( 'parse_request', 'simplify_nested_json', 0 );
    function simplify_nested_json( $wp ) {
        // Check if the request is /simplify-json
        if ( 'simplify-json' !== $wp->request ) {
            return;
        }
    $url ='https://data.gov.il/api/3/action/datastore_search?resource_id=2de7b543-e13d-4e7e-b4c8-56071bc4d3c8&limit=3000';
    $JSON = file_get_contents($url);
    // echo the JSON (you can echo this to JavaScript to use it there)
    // You can decode it to process it in PHP
    $data = json_decode($JSON);
        // Array version of the JSON data.
        // Send headers.
        status_header( 200 );
        nocache_headers();
        header( 'Content-Type: application/pkcs7-mime' );
        // And serve the JSON data.
         echo wp_json_encode($data->result->records );
        exit;
    }

    This code turns the nested JSON to a flat one.
    * Change the $url with your required API URL.
    * Change this part $data->result->records with the rout to the requested part of the JSON
    * Add https://yoursite.com/simplify-json “Input JSON URL” field.

    • This reply was modified 1 year, 12 months ago by vedante30.
    • This reply was modified 1 year, 12 months ago by vedante30.

    The previous post was not good… I needed to add a special Quary to The index.php to avoid Date and Ordring problems.
    This is the right code:

    <?php
    // Query featured entries
    $home_events= new WP_Query(
        array(
            'post_type'			=> array( 'post', 'tribe_events' ),
            'eventDisplay'=> 'upcoming',
            'meta_key' => '_EventStartDate',
            'orderby' => '_EventStartDate',
            'order' => 'ASC',
            'no_found_rows'			=> false,
            'update_post_meta_cache'	=> false,
            'update_post_term_cache'	=> false,
            'ignore_sticky_posts'		=> 1,
            'posts_per_page'		=> ot_get_option('featured-posts-count'),
    	)
    );
    ?>
    <?php get_header(); ?>
    
    <section class="content">
    
    	<?php get_template_part('parts/page-title'); ?>
    
    	<div class="pad group">
    
    		<?php if ( hu_is_checked('featured-posts-enabled') ) { get_template_part('parts/featured'); } ?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php if ( hu_get_option('blog-standard') == 'on' ): ?>
    				<?php while ( $home_events->have_posts() ): $home_events->the_post(); ?>
    					<?php get_template_part('content-standard'); ?>
    				<?php endwhile; ?>
    			<?php else: ?>
    			<div class="post-list group">
    				<?php $i = 1; echo '<div class="post-row">'; while ( $home_events-> have_posts() ): $home_events-> the_post(); ?>
    					<?php get_template_part('content'); ?>
    				<?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    			</div><!--/.post-list-->
    			<?php endif; ?>
    
    			<?php get_template_part('parts/pagination'); ?>
    
    		<?php endif; ?>
    
    	</div><!--/.pad-->
    
    </section><!--/.content-->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Find a solution:
    Add this line to index.php:
    <?php if( is_home() && !is_paged() && $wp_query->current_post <= 1 ) continue; ?>

    So the whole code look like this:

    <?php get_header(); ?>
    
    <section class="content">
    
    	<?php get_template_part('parts/page-title'); ?>
    
    	<div class="pad group">
    
    		<?php if ( hu_is_checked('featured-posts-enabled') ) { get_template_part('parts/featured'); } ?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php if ( hu_get_option('blog-standard') == 'on' ): ?>
    				<?php while ( have_posts() ): the_post(); ?>
                                            <?php if( is_home() && !is_paged() && $wp_query->current_post <= 1 ) continue; ?>
    					<?php get_template_part('content-standard'); ?>
    				<?php endwhile; ?>
    			<?php else: ?>
    			<div class="post-list group">
    				<?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
    					<?php get_template_part('content'); ?>
    				<?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    			</div><!--/.post-list-->
    			<?php endif; ?>
    
    			<?php get_template_part('parts/pagination'); ?>
    
    		<?php endif; ?>
    
    	</div><!--/.pad-->
    
    </section><!--/.content-->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Hi! Thanks for your help Via Hueman Template, it is really helpful!
    I have one question, maybe you can assist.
    How do i hide the events from the Futured slider to appear second time after the slider?

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