• Resolved scottiescotsman

    (@scottiescotsman)


    I want to be able to list my metadata [in a drop down menu] from a custom post type so that I can make a custom loop.
    For instance:
    if I wanted archive-movies to list dependent on release date or alphabetically or its duration.

    Hope someone can help
    Steven

Viewing 9 replies - 1 through 9 (of 9 total)
  • You can retrieve meta data with the get_metadata()

    First 2 arguments are required, type and object_id

    From there you should be able to retrieve all metadata and do with it as you may

    Thread Starter scottiescotsman

    (@scottiescotsman)

    yes I know that as I have it in archives-movies.php & single-movies.php

    <p class="align_Right">
    
        	<select name="movieList" id="movieList">
    
                <option value="0">Select List Order...</option>
                <option value="dateAscending">Date Ascending</option>
                <option value="dateDescending">Date Descending</option>
                <option value="alphaUp">Alpha Ascending</option>
                <option value="alphaDown">Alpha Descending</option>
        
    		</select>
            
            <input class="btnSort" type="submit" value="Go" name="sort">
            
        </p>
    
    <?php 
                        
        $nam = get_post_meta( get_the_ID(), "name", true );
        $rel = get_post_meta( get_the_ID(), "released", true );
       $rat = get_post_meta( get_the_ID(), "rating", true );
       $dur = get_post_meta( get_the_ID(), "duration", true );
       $gen = get_post_meta( get_the_ID(), "genre", true );
        $dir = get_post_meta( get_the_ID(), "director", true );
           $wri = get_post_meta( get_the_ID(), "writer", true );
          $sta = get_post_meta( get_the_ID(), "stars", true );
         $sto = get_post_meta( get_the_ID(), "storyline", true );
         ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    its how to link it into the loop I cant figure out.

    You would move your code into the loop, the loop changes the post and get_the_ID() result each go around.

    Thread Starter scottiescotsman

    (@scottiescotsman)

    I have it working on my site but it lists it in order of when I added the movie, I want to change that to whatever option I choose.

    You can create a custom WP_Query() and order it however you would like: WP_Query

    Thread Starter scottiescotsman

    (@scottiescotsman)

    that’s what I want to know lol

    <select name="movieList" id="movieList">
        
                    <option value="0">Select List Order...</option>
                    <option value="dateAscending">Date Ascending</option>
                    <option value="dateDescending">Date Descending</option>
                    <option value="alphaUp">Alpha Ascending</option>
                    <option value="alphaDown">Alpha Descending</option>
            
                </select>
                
                <input class="btnSort" type="submit" value="Go" name="sort">
                
            </p>
            
        <?php 
    	
    		$nam = get_post_meta( get_the_ID(), "name", true );
    		
    		$query = new WP_Query( array( 'category_name' => ' $nam ' ) );
            
       		if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    		
    	?>

    Did you follow the link to see an example?

    Thread Starter scottiescotsman

    (@scottiescotsman)

    yes I have seen a few but I am new to wordpress and I have been struggling with the code.

    Thread Starter scottiescotsman

    (@scottiescotsman)

    yoohoo anyone home ?

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘custom loop from metadata’ is closed to new replies.