WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] i want to get posts based on page name (8 posts)

  1. sheriffderek
    Member
    Posted 1 year ago #

    so on a record label website, there are pages of artists. my goal was to use the same template for all. below the bio section, i wanted to get posts for that artist. the posts are tagged "news" but i only want news from the artist. without making individual themes - i thought i would do this by getting the posts by page title - since the page title is also the artists name.

    so - get post of the category that is the same as the page-title.

    first attempt was to insert echo like this


    <?php query_posts('category_name=posts&showposts=0') ?>

    which pulls all "posts"
    then figured i could add an echo in there in place -


    <?php query_posts('category_name=<?php echo get_the_title($ID); ?> &showposts=0') ?>

    but no go-

    any ideas ? i think i'm going about this all wrong - but i can't wrap my head around it. ? ? ? i want my client to be able to create new pages without my help... and this would solve that issue.

    thanks.

  2. fordp
    Member
    Posted 1 year ago #

    So you have a page like:

    "Sheriff Derek"

    and then you have posts that have been placed in a category called "sheriff derek".

    Try this code:

    <?php
    $artistcat = get_the_title();
    query_posts('category_name=$artistcat'); ?>
  3. President McCheese
    Member
    Posted 1 year ago #

    <?php query_posts('category_name=' . strtolower(the_title('','',false)) . '&showposts=0'); ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
  4. President McCheese
    Member
    Posted 1 year ago #

  5. sheriffderek
    Member
    Posted 1 year ago #

    thank you 2 for your replies. i still haven't worked it out... but i did start wondering about re-setting my queries. so i did... and that cleared up some other issues... so then i went back and tried your examples again... but i've had no luck.

    here are some up to date examples:

    <div class="entry">
    			<img alt="release image" src="<?php echo get ('artists_image') ?>"> <br />
    			<div class="blog-text">
    				<h2 class="header"><?php echo get ('artists_name') ?> :</h2>
    			</div>
    			<div class="blog-text">
    				<?php echo get ('artists_bio') ?>
    			</div>
    				<br/>
    		</div> <!--end entry-->

    no problem getting the info here... out of the loop.

    <?php query_posts( array(
    			'artist' => 'san-gabriel',
    			'showposts' => 3
    			) ); ?>

    getting shows:

    <?php query_posts( array(
    			'cat' => 'shows',
    			"order" => 'desc',
    			'orderby' => 'meta_value',
    			'meta_key' => 'show_info_date',
    			'artist' => 'san-gabriel'
    			) ); ?>

    getting relative posts:

    now "san-gabriel" is the artist name in this case (both of these queries are right before their loops. and the loops are reset.)

    both of the previous responses make total sense to me logically... but they break the page... is there anything in these examples that might show what exactly i am not understanding ? thank you so much for even taking the time to read this. -dw

  6. sheriffderek
    Member
    Posted 1 year ago #

    <?php wp_title("",true); ?> <br />
    this returns San Gabriel
    <?php echo get ('artists_name') ?>
    this also returns San Gabriel

    <?php query_posts( array(
    	'artist' => 'san-gabriel',
    	'showposts' => 3
    	) ); ?>

    my aim is to replace san-gabriel here - with one of the above...

  7. sheriffderek
    Member
    Posted 1 year ago #

    http://wordpress.org/support/topic/query-by-a-custom-field-echo?replies=4#post-2839817

    accidentally got so worked up i started a second post without remembering the first !!! sorry !!!

    anyways - post got solved !!! thanks to everyone who chimed it !!!

  8. sheriffderek
    Member
    Posted 1 year ago #

    http://wordpress.org/support/topic/query-by-a-custom-field-echo?replies=4#post-2839817

    here is the other thread... i am terrible with using this text box...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.