Wordpress Posts Not Showing Properly

Hello,

I have had a ticket open before for this with no exact resolution. The thing I didn't include was the PHP code for the "Video Template". The problem I have with this video template is, it displays ALL my posts rather than the specific category selected. I have my posts, categories, and pages all named and selected properly. For some reason this "Video Template" displays everything not just what I have selected. I was thinking someone may be able to know some code I can add or take out from the editor page. The developer has no support for this theme that is why I came here. Thank you:

<?php
/**
* Template Name: Video Archive Page
* Description: Displays a full width page for video posts.
*
* @package Audonic
*/

get_header( 'alt' ); ?>

<?php

// Define custom query parameters
$custom_query_args = array(

	'tax_query' => array(
		array(
			'taxonomy' => 'post_format',
			'field' => 'slug',
			'terms' => array( 'post-format-video' ),
		)
	),
);

// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

// custom query
$custom_query = new WP_Query( $custom_query_args );
// Pagination fix
$temp_query = $wp_query;
$wp_query   = NULL;
$wp_query   = $custom_query;
?>
	<?php if ( get_theme_mod( 'display_archive_header_hero' ) == '1' )  : ?>
			<?php
	$bkgdImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
	?>
	<div class="col-width hero-header">
		<div class="hero-featured-post" id="hero-background" style="background-image:url('<?php echo esc_url($bkgdImg['0']);?>');background-repeat:no-repeat;background-size:cover;background-position: center center;">
			<div class="archive-background-overlay">
				<div class="header-hero-container">

					<div class="hero-title">
						<div class="hero-title-inside">

							<?php
						the_title( '<h1 class="page-hero-title">', '</h1>' );
						?>


						</div><!-- .hero-title-inside -->
					</div><!-- .hero-title -->

				</div><!-- .header-hero-container -->
			</div><!-- .background-overlay -->

		</div><!-- .header-hero-container -->
	</div><!-- .background-overlay -->

	<div class="col-width clearfix">

<?php else : ?>

	<div class="col-width clearfix">

		<header class="page-header">
			<?php
		the_title( '<h1 class="page-title">', '</h1>' );
		?>
	</header><!-- .page-header -->

<?php endif; ?>


	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

	<?php if ( $custom_query->have_posts() ) : ?>

		<div class="showcase">

			<?php /* Start the Loop */ ?>
			<?php while ( $custom_query->have_posts() ) : $custom_query->the_post();
				// Set default image sizes to use
			$thumbnail = 'audonic-feature-showcase';
			$width = 640;
			$height = 360;

			// If no image is set, we'll use a fallback image
			if ( has_post_thumbnail() ) {
				$image = wp_get_attachment_image_src( get_post_thumbnail_id(), $thumbnail, true );
				$image = $image[0];
				$class = "image-thumbnail";
			} else {
				$image = get_template_directory_uri() . '/img/image.svg';
				$class = 'fallback-thumbnail';
			}
			?>

			<article id="post-<?php the_ID(); ?>" <?php post_class( 'module' ); ?>>
				<a href="<?php the_permalink(); ?>" class="entry-image-link">
					<figure class="entry-image <?php echo esc_attr($class); ?>">
						<img src="<?php echo esc_url( $image ); ?>" width="<?php echo esc_attr($width); ?>" height="<?php echo esc_attr($height); ?>">
					</figure>
				</a>

				<header class="entry-header">
					<?php the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>
				</header><!-- .entry-header -->

						<div class="entry-content clearfix">
						<?php echo audonic_get_featured_excerpt( 140 ); ?>
						</div><!-- .entry-content -->
						<footer class="entry-meta">
							<ul class="entry-meta-taxonomy">
									<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
										<?php
									$categories = get_the_category();
									$separator = '';
									$output = '';
									if ( $categories ) {
										foreach ( $categories as $category ) {
											$output .= '<li class="category-link"><a href="'.get_category_link( $category->term_id ).'">'.$category->cat_name.'</a></li>'.$separator;
										}
										echo trim( $output, $separator );
									} // End get_the_category() ?>
									<?php if ( get_the_tag_list() ) {
										echo get_the_tag_list( '<li>', '</li><li>', '</li>' );
									} // End get_the_tag_list() ?>

										<?php endif; // End if 'post' == get_post_type() ?>

										<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
										<li class="comments-link"><?php comments_popup_link( esc_html__( 'Comment', 'audonic' ), esc_html__( '1 Comment', 'audonic' ), esc_html__( '% Comments', 'audonic' ) ); ?></li>
										<?php endif; ?>

										<?php edit_post_link( esc_html__( 'Edit', 'audonic' ), '<li class="edit-link">', '</li>' ); ?>
							</ul>
						</footer><!-- .entry-meta -->
					</article><!-- #post-## -->

	

			<?php
					endwhile; ?>

       	</div><!-- .showcase -->

		<?php if ($custom_query->max_num_pages > 1 ) { // check if the max number of pages is greater than 1  ?>
<nav class="navigation paging-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php esc_html_e( 'Posts navigation', 'audonic' ); ?></h1>
		<div class="nav-links module">

			<?php if ( get_next_posts_link() ) : ?>
				<div class="nav-previous"><?php next_posts_link( '<i class="fa fa-angle-double-left" aria-hidden="true"></i> Older posts', $custom_query->max_num_pages ); ?></div>
			<?php endif; ?>

			<?php if ( get_previous_posts_link() ) : ?>
				<div class="nav-next"><?php previous_posts_link( 'Newer posts <i class="fa fa-angle-double-right" aria-hidden="true"></i>' );?></div>
			<?php endif; ?>

		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
<?php } ?>

<?php else : ?>
			<?php get_template_part( 'partials/content', 'none' ); ?>
		<?php endif; ?>

		<?php 
			// Reset main query object
		$wp_query = NULL;
		$wp_query = $temp_query; 
		wp_reset_postdata();    
		?>  



		</main><!-- #main -->
	</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Open in new window

WO2015Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Code tags added: To add code tags
1. Highlight your code
2. Click the CODE tag in the tool bar
CodeTags.jpgWhere are you specifying the category you want in your query
'tax_query' => array(
		array(
			'taxonomy' => 'post_format',
			'field' => 'slug',
			'terms' => array( 'post-format-video' ),
		)
	),

Open in new window

0
WO2015Author Commented:
Thank you, sorry I had no idea that "tags" existed on there.

For example I have a page called Recipes and I have a few video's under the category "Recipes". I have the "Video Template" selected and JUST the category "Recipes" selected on my page. Rather than just showing that 1 category its showing ALL video posts I have made.

Another example I have a page called The Following Announcement and I have a few video's under the category "TFA". I have the "Video Template" selected and JUST the category "TFA" selected on my page. Rather than just showing that 1 category its showing ALL video posts I have made.
0
Julian HansenCommented:
I understand the problem - but in your code your query is not filtering on category. In other words there is nothing in your code that is telling WP to only return you posts in a particular category. Does this make sense?

You need to add a category filter to your query.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

WO2015Author Commented:
Makes since which was one of my thoughts in my original question. I do not know what to do about it. I am not sure what a category filter to a query means. I am a novice with wordpress but have the basic understanding. That is why I purchase themes, unfortunately this one did not have support included which lead me to come here hoping someone could help to get it working.
0
Julian HansenCommented:
Take a look at the get_posts() page

You are using a custom query rather than get_posts() is there a reason for this?

With get_posts() you do this
$args = array (
  'category' => 1, // replace with the id of the Category you are interested in
  'post_type' => 'posts'
);
$posts = get_posts($args);
foreach($posts as $post) {
   // rest of your foreach loop here
}

Open in new window


If you look at the args section you will see one of the arguments you can pass is category
0
WO2015Author Commented:
Hello,

I purchased this theme. I have no idea why things are what they are, I just got it because it fit my needs. However I did not know this category thing would be so difficult when it should be very simple. I am fine with changing any code but I do not have the experience or knowledge to understand what to change.

I see the section you have above which says "replace with the id of the Category you are interested". Where do I do this at? Wouldnt I have to edit each specific page?
0
Julian HansenCommented:
If this is theme code then you need to log a support request with the person who wrote the theme.
0
WO2015Author Commented:
That is what I am trying to understand here because there is no support. I have tried and they said this theme is not supported. So is there nothing I can do within the editor and code?
0
WO2015Author Commented:
I own the them, I purchased it. But it is not supported which is why I am here.
0
Julian HansenCommented:
Unfortunately you have two options
1. Get hold of the author to find out why the theme is not functioning as expected - that you paid for it means there should be some support
2. Be prepared to modify the the theme file.

From what I can tell the theme is not looking at categories but at the post_format taxonomy for posts with the following term
post-format-video

Open in new window


Go to your post and add the post-format-video term to the post_format taxonomy for the post and see if that works.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WO2015Author Commented:
1. I have tried and I agree 100%.
2. Thank you for looking into this.
0
Terry WoodsIT GuruCommented:
Bear in mind that if you edit a theme file, then install an update to the theme, your edit will be lost. The way around this is to use a Child Theme.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.