0
I have a Wordpress template with Multiple post type, and I can query and display all Custom post type on index.
My Custom post type is an area reserved only for Movies, Series and Blog, only in my index I only show the Movies and Series because they appear the same.
Ex. how it appears in my index:
How my blog post appears:
But my doubt and the following, as I can show all these posts in my index, like, I use a different model in the area of the blog, I show only an image and a description, already in my area of movies and series I show various information.
How do I distinguish posts to display all on index and without getting bugged?
<?php $args = array('post_type'=>array('filmes', 'series')); query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if (has_post_thumbnail()) {
$imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'home');
$imgsrc = $imgsrc[0];
} elseif ($postimages = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=0")) {
foreach($postimages as $postimage) {
$imgsrc = wp_get_attachment_image_src($postimage->ID, 'home');
$imgsrc = $imgsrc[0];
}
} elseif (preg_match('/
<img [^>]*src=["|\']([^"|\']+)/i', get_the_content(), $match) != FALSE) {
$imgsrc = $match[1];
} else {
$imgsrc = get_template_directory_uri() . '/images/no-imagen.png';
} ?>
I know that to display blog area posts just add in the array after post_type, but when it appears buggy the view part.
Ex.:
You can make a
if
using the function responseget_post_type
– Valdeir Psr
You could give me an example of how to get started, I’m not good at PHP, just manjo in html and css, PHP I just untangled by the tutorials.
– Vitor Hugo
Example. Within that
if
, just assemble the layout in accordance with the post type.– Valdeir Psr
used and it worked, however, I will have to modify the entire template, because only to show the post of a movie I make the query of approximately 10 different taxonomies to display the values, I used the function 'echo' to show, there is some other method to display without having to adapt the code, I mean, just paste the pure code without having to do the queries and then display it like '.$value.'
– Vitor Hugo
type, to query the quality for example, I use this function "<? php if($values = get_post_custom_values("item_quality")) { ? ><? php echo $values[0]; ? ><? php } ? >" how do I put it inside if without having to adapt it to '.$value.'
– Vitor Hugo