WordPress.org

Ready to get started?Download WordPress

Forums

Recipe Card
[resolved] Get Image and Title (3 posts)

  1. ibreezer
    Member
    Posted 1 year ago #

    Hi I want to create an index page much like the one you use yourselves on your site with just image and title and once you click on it you'll get the full post with the entire recipe, so my question how would you go about to get the image and title in the simpliest way?

    Thanks in advanced.

    http://wordpress.org/plugins/recipe-card/

  2. Yumprint.com
    Member
    Plugin Author

    Posted 1 year ago #

    Hi -

    Our plugin doesn't support what you are describing, but you could build something yourself using the information in the database. You should be able to access both the title and the image in the yumprint-recipe database.

  3. ibreezer
    Member
    Posted 1 year ago #

    Well i made my own custom solution if anyone else would be intrested in creating a index/archive/category page for recepies

    <?php
    	global $wpdb;
    	global $post;
    	$table_name = $wpdb->prefix . "yumprint_recipe_recipe";
    	$recipe_rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name"),ARRAY_A);
    	foreach($recipe_rows as $recipe){
    		$content = json_decode($recipe['recipe']);
    		$post = get_post( $recipe['post_id'], OBJECT );
    		setup_postdata( $post );
    		?>
            <div <?php post_class(); ?>>
    
            <div class="entry-content">
    
            <a href="<?PHP the_permalink();?>"><img src="<?PHP echo $content->image;?>" /></a>
    
            </div>
            <h3><?PHP the_title();?></h3>
            <?PHP
    
    		$content->title;
    		?>
            </div>
            <?PHP
    	wp_reset_postdata();
    	}
    
     ?>

    you can access all recipe data from the $content object here's a list

    $content->title;
    $content->image;
    $content->author;
    $content->adapted;
    $content->adaptedLink;
    $content->summary;
    $content->prepTime;
    $content->cookTime;
    $content->totalTime;
    $content->servings;
    $content->yields;
    $content->ingredients;

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.