structured data in home page. Created section to loop content

This commit is contained in:
jorge 2022-12-29 00:18:04 +01:00
parent 3351d0eeb6
commit 8dfef5a2c6
3 changed files with 85 additions and 48 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Template part for displaying featured "ajuts" and widgets * Template part for displaying featured posts or "ajuts" and widgets
* *
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
* *
@ -21,53 +21,62 @@
<h1> <?php echo esc_html__('Destacats', 'ofisuport'); ?></h1> <h1> <?php echo esc_html__('Destacats', 'ofisuport'); ?></h1>
</header> </header>
<main id="destacats" class="ofisuport-destacats ofisuport-featured"> <main id="destacats" class="ofisuport-destacats ofisuport-featured">
<?php //get_template_part( 'template-parts/loop', 'posttype-category-number'); ?>
<?php
<?php // https://developer.wordpress.org/reference/functions/get_posts/
// https://developer.wordpress.org/reference/functions/get_posts/ // https://www.advancedcustomfields.com/resources/true-false/
// https://www.advancedcustomfields.com/resources/true-false/ $the_query = new WP_Query(
$the_query = new WP_Query( array(
array( 'post_type' => 'any',
'post_type' => 'any', 'post_per_page' => '4',
'post_per_page' => '4', 'meta_query' => array(
'meta_query' => array( array(
array( 'key' => 'os_home_show',
'key' => 'os_home_show', 'value'=> '1',
'value'=> '1', )
) )
) ) );
) ); ?>
?> <?php if ( $the_query->have_posts() ) : ?>
<?php if ( $the_query->have_posts() ) : ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<article class="">
<article class=""> <h3 class="entry-title">
<h3 class="entry-title"> <a href="<?php the_permalink(); ?>" rel="bookmark">
<a href="<?php the_permalink(); ?>" rel="bookmark"> <?php the_title(); ?>
<?php the_title(); ?> </a>
</a> </h3>
</h3> <?php if( get_field('os_funder_name') ): ?>
<section class="excerpt post-excerpt"> <p class="ofisuport-funder-name"><?php the_field('os_funder_name'); ?></p>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"> <?php endif; ?>
<?php the_excerpt() ?> <section class="excerpt post-excerpt">
</a> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
</section> </a>
<button class="button button-more" > <?php the_excerpt() ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">accedeix</a> </section>
</button> <aside>
</article> <?php get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'os_fund_target') ); ?>
<?php get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'os_fund_source') ); ?>
<?php endwhile;//end of the loop ?> <?php get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'os_fund_field') ); ?>
<?php wp_reset_postdata(); ?> <?php get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'os_fund_apply_begin') ); ?>
<?php else : //if no post in query ?> <?php get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'os_fund_apply_end') ); ?>
<p class="no-content"></p> <?php get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'os_fund_call') ); ?>
<?php endif; //end query ?> </aside>
<button class="button button-more" >
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">accedeix</a>
</button>
</article>
<?php endwhile;//end of the loop ?>
<?php wp_reset_postdata(); ?>
<?php else : //if no post in query ?>
<p class="no-content"></p>
<?php endif; //end query ?>
</main> </main>
<?php } //closing if is_plugin_active ?> <?php } //closing if is_plugin_active ?>
<?php // including widget area for front page only ?> <?php dynamic_sidebar( 'front-page-widgets' ); // including widget front page?>
<?php dynamic_sidebar( 'front-page-widgets' ); ?>
</aside> </aside>

View File

@ -0,0 +1,28 @@
<?php
/**
* Template part for displaying a list with data checked in checkbox list
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Oficina_de_Suport_theme
*/
?>
<?php
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
// var_dump( $args ); //will display everythin imported from
// get_template_part( 'template-parts/section', 'list-checkbox', array('os_acf_field' => 'CHANGETHIS') );
$fielditerate = $args['os_acf_field'];
?>
<?php
$values= get_field($fielditerate);
if( $values ):
?>
<ul class="oficina-support-label color-<?php echo $fielditerate ?>">
<?php foreach( $values as $value ): ?>
<li><?php echo $value; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>