php - Wordpress Trying to use get_title() in loop array as the category name -


on wordpress page template im trying use get_title() in arguments array loop cant return posts.

this im to;

<?php              $args = array(                        'category_name' => 'the_title();'                    );              $the_query = new wp_query( $args ); ?>  <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>              <div class="entry"><?php the_content(); ?></div>  <?php endwhile; else: ?>      <p>sorry, there no posts display</p>  <?php endif; ?> 

im unable posts return on page unless manually enter slug category want use not ideal page slug same post category slug.

my logic behind dont want have individual page templeate each page different cat end hundreds of page templetes.

any appreciated cheers jon

you're passing the_title(); string ' '. also, the_title() gets title of object in loop, not of category.
can following:

 global $post;   $args = array('category_name' => $post->post_name); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -