oficinasuport-wp-theme/template-parts/section-featured.php

71 lines
1.9 KiB
PHP

<?php
/**
* Template part for displaying featured "ajuts" and widgets
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Oficina_de_Suport_theme
*/
?>
<aside>
<?php
// Detect plugin. For use on Front End only.
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// check for plugin using plugin name
if ( is_plugin_active( 'oficinasuport-wp-plugin/ofisuport-wp-plugin.php' ) ) {
//plugin is activated do
?>
<header>
<h1> <?php echo esc_html__('Destacats', 'ofisuport'); ?></h1>
</header>
<main id="destacats" class="ofisuport-destacats ofisuport-featured">
<?php //get_template_part( 'template-parts/loop', 'posttype-category-number'); ?>
<?php
// https://developer.wordpress.org/reference/functions/get_posts/
// https://www.advancedcustomfields.com/resources/true-false/
$the_query = new WP_Query(
array(
'post_type' => 'any',
'post_per_page' => '4',
'meta_query' => array(
array(
'key' => 'os_home_show',
'value'=> '1',
)
)
) );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<article class="">
<h3 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h3>
<section class="excerpt post-excerpt">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<?php the_excerpt() ?>
</a>
</section>
</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>
<?php } //closing if is_plugin_active ?>
<?php // including widget area for front page only ?>
<?php dynamic_sidebar( 'front-page-widgets' ); ?>
</aside>