Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Añade queries a tu tema con WP_Query
<?php
/**
* Query random comic reviews
*/
$args = array(
'post_type' => 'scv_comic_review',
'posts_per_page' => 2,
'orderby' => 'rand'
);
$comicReviews = new WP_Query( $args );
echo '<aside class="random-comic-reviews">';
while( $comicReviews->have_posts() ): $comicReviews->the_post();
echo '<div class="comic-review">';
echo '<a href="'.get_permalink().'">';
the_post_thumbnail('medium');
echo '<h1>'.get_the_title().'</h1>';
echo '</a>';
echo '</div>';
endwhile;
echo '</aside>';
wp_reset_query();
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/post/content', 'scv_comic_review' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
the_post_navigation( array(
'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
) );
endwhile; // End of the loop.
get_template_part( 'comic-reviews' );
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
</div><!-- .wrap -->
<?php get_footer();
/*
Theme Name: Twenty Seventeen Child
Theme URI: https://silicodevalley.com
Author: David Perálvarez
Author URI: https://silicodevalley.com
Description: Twenty Seventeen with CPT and CT support
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: tschild
Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
Template: twentyseventeen
*/
.post-type-archive-scv_comic_review .entry-taxonomies,
.tax-scv_comic_author .entry-taxonomies,
.tax-scv_comic_genre .entry-taxonomies,
.single-scv_comic_review .entry-taxonomies{
background-color: #eee;
padding: 10px 20px;
margin-bottom: 30px;
}
.post-type-archive-scv_comic_review .entry-taxonomies a,
.tax-scv_comic_author .entry-taxonomies a,
.tax-scv_comic_genre .entry-taxonomies a,
.single-scv_comic_review .entry-taxonomies a{
text-decoration: underline;
}
.review-tag{
background-color: Beige;
color: DarkGoldenRod;
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
margin-bottom: 10px;
}
.random-comic-reviews .comic-review{
width: 50%;
float: left;
padding: 0 .5rem;
}
.random-comic-reviews .comic-review img{
display: block;
margin: 0 auto;
}
.random-comic-reviews .comic-review h1{
background-color: Beige;
color: DarkGoldenRod;
padding: 4px 8px;
margin-bottom: 10px;
text-align: center;
font-size: 16px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.