Need post Images display in widget by Post ID

Anyone Know of a plugin that will create a thumbnail inside a widget from a post. Would like to have image/post selected by post ID# or title. Premium or freebie!

Thanks!
Be Blessed!

  • Imperative Ideas

    How well do you know the post loop?

    You should be able to fetch the thumbnail image from within your post and display it in the widget. You could even set the widget not to fire if no image were available. The widget should obey the same wp_query rules as the rest of the page. That's the basic premise of things like recent comments & recent posts widgets.

    This will walk you through the process of creating a widget. It's not all that difficult if you have even a novice level foundation in PHP... about on par with shortcode construction, provided you don't get into plugin land with custom data tables.

    http://wp.tutsplus.com/tutorials/creative-coding/building-custom-wordpress-widgets/

    What image are you trying to pull?

  • Mark Wallace

    Hello @Imperative Ideas

    I will looked at the tutorial, but i need to create about 60-100 widgets per page, and have 1 post ID for each image.

    I have a plugin that will let me place in the content area in rows and columns. It just seems that all the plugins to feed post into widgets falls short of using the post ID, they use categories and CPT, even authors, but not post ID. lol

    To try the widget loops is something i would love to learn, but am under time restraints, so looking for a plugin for now!

    But thank you for the tutorial, i will save this link to share with others, and hopefully once things slow down i can learn this.

    Thanks Again!
    Be Blessed!

  • Mark Wallace

    lol people "users" will already of a Code to enter into a Gravity Form field. Part of that process will pre-populate the post ID.

    Once that post is uploaded via the Gravity Form, i want a thumbnail to display on a page. Each entry code will have a predetermined location "widget" that it is assigned to using the post ID.

    There is no sign ups or memberships, so using the author will not work, and since there will be up to 6,000 entries per category, i can not use the category to separate, the images either!

    Does this make more since? :slight_smile:

    If you know of an easier way "better" way i am open to suggestions! lol

    Thanks!
    Be Blessed!

  • Mark Wallace

    My apologies if I'm not understanding correctly.

    I think you understand, but this is not something i know how to do! lol

    It may be easier to have the gravity form populate a custom post type,

    I remember reading about this, and can do it!

    then display the images by pulling the CPT back into a page loop.

    i have looked into the loop on other plugin for other projects, it is not something i have a grasp as of yet. If i can learn it in a few hours or even 8 hours, then i could use it, but time is not on my side! So If you got a step by step instruction i am diffidently game

    Doing it with widgets seems like overkill since you are (as far as I can tell) just displaying post data in a sequential order.

    They can be in random order if need be, but need them to be page specific. there are 100 pages per category with 60-100 thumbnails per page that need to be displayed, and they need to link back to the post.

    Wither plugin, widget or loop it is going to be a long task, that is why i cannot spend to much time learning something at the moment, need to get started in about 36 hours.

    So If you got a step by step instruction i am diffidently game, but have to be sure it will work before spending a day learning it!

    Thanks!
    Be Blessed!

  • Imperative Ideas

    It's a lot easier than you are making it, that's for sure. I'm not sure 8 hours with no prior experience is realistic though. Generating the CPT is easy enough. You then have to make your form store post content on the front end... tutorials exist. Then you have to style your output through the post loop.

    If you were a client I'd quote you about $500 for the system. 8 hours would be a tight deadline for a first time attempt. Writing widgets though? No way dude. If anything you would write it as a plugin.

  • Mark Wallace

    Sorry for the late response, i entered that dark scary place called sleep! lol I have threads in multiple forums looking for a easy solution.

    tutorials exist.

    I have not found them in Gforms knowledge base, is there another place i can find these tutorials?

    If i decide to bid this out, i will post it on the WPMU Dev jobs board, and post a link back here so you can add your bid. :slight_smile:

    Thanks for guidance!
    Be Blessed!

  • Imperative Ideas

    We just need to invoke your sense of adventure :slight_smile:

    http://gravitywiz.com/2012/04/21/use-gravity-forms-to-create-user-submitted-posts/

    That pretty much covers the topic of how to do what you are asking, including a link to the Gravity Forms plugin for Custom Post Type integration.

    You can create a custom post type using either this generator (good for building the post type directly into the theme) or the CustomPress plugin here at WPMUdev (plugin based so the post admin will survive a theme change without modification). Generally speaking, I prefer to include the custom post type in the theme using a linked file. I call it out of functions.php like this:

    require_once( trailingslashit( get_stylesheet_directory() ) . 'inc/functions/cpt.php' ); // Add Custom Post Types

    Please note that this is the child-theme code. A standalone theme would typically use this version:

    require_once( trailingslashit( get_template_directory() ) . 'inc/functions/cpt.php' ); // Add Custom Post Types

    That is just my preference though, yours may differ. I take a very manual & obsessively organized approach to my functions.php file.

    So we've got two components:

    1. Generate the custom post type
    2. Post user generated content using Gravity forms

    Now all you need to do is spit that content back out using a post loop. There is no reason you can't take a visual approach, like this, where the image & title field link to a full post.

    When you get to that point, we can talk about formatting your loop.

    The nice thing about this approach is that all of your user generated posts will show up in the custom post type admin on your back-end so that you can moderate/edit/delete them with the same interface used for pages + blog items.

    Get the first two steps working then check back in.

  • Imperative Ideas

    One thing I should mention, as I do not know your level of expertise.

    If you link the generated custom post type code, the file should look like this:

    File: path_to_directory/cpt.php (or whatever file name you chose)

    `<?php

    //Generated Functions Code Goes Here

    ?>'

    In an oddity of WP functions (well php includes, really) it is critical that you include the opening PHP tag but the closing tag is optional. You cannot simply drop the generated code into a file without the opening tag or you will get an error.

  • Mark Wallace

    lol i have been trying to do the CPT in a child theme, just keep getting about 8 lines of errors.

    Now i got it down to two 4 lines with a space between the Warning: require_once and the Fatal error: require_once little improvement.

    I must need to create a directory, going to check Google, ok that was a little confusing, I take it there are many ways to do this, so i am going to stick with you! lol

    I am guessing that i need to create a folder, or file some where in the data base! See snip shot, and if that is correct please tell me where to place it. I would rather learn to place this in the theme.

    I am going to keep reading, will keep an eye out for your response!

    Thanks!
    Be Blessed!

  • Imperative Ideas

    Yeah sorry... the way it's notated was from my personal theme boilerplate.

    From the root. cpt.php is in inc/functions/cpt.php in my build.

    If you put your post type in the root, it would just be cpt.php with nothing else on the line. If all else fails, drop the code directly into functions.php.

    My personal preference is for keeping function groups separated so I don't get 3500 lines of code in functions.php. You don't have to do it that way. In fact, you really could just use CustomPress if you aren't comfortable building it into the theme.

  • Imperative Ideas

    When you have time, some of the best money you'll spend is at Lynda.com. The sub is month to month and it's downright cheap compared to ones like WPMUdev because it doesn't have to be maintained after you get what you need out of the company.

    Try to make the time for a couple of courses if you aren't up to speed. This one in particular will make you a better theme developer:

    Working with custom post types

    If that's jumping ahead too far then start here:

    WordPress 3: Creating and Editing Custom Themes

    If you don't have a comprehensive grasp of CSS, there are other courses for that as well. If you go through the two I linked though, you'll be way ahead of 85% of the people trying to make money on WordPress.

  • Mark Wallace

    Good Morning! @Imperative Ideas

    I got some test CPT set up with CustomPress, and have the gravity forms user created post set up. Done some test post and ready for some more. So when you get time give me the next steps.

    Try to make the time for a couple of courses if you aren't up to speed. This one in particular will make you a better theme developer:

    I have looked for php hook ups, but there is none in this area, it is hard to find anyone to take the time and teach, so i am very thankful that you have. :slight_smile: I will defiantly look into the links you provided, i am helping a friend with a real world event that takes place this Saturday, and compiling addresses for a "Traditional" Mail Marketing campaign for Monday or Tuesday "have to check the calendar" lol

    That and my personal projects have really taken away from my learning time, Hope after next week to be settled back into my learning phase! Only build sites on a charity base right now, and personal projects, Mostly "Real World Community Out Reach" type projects, but of course what life be without big goals and dreams. :slight_smile:

    Any Way Ready for the next lesson!

    Thanks! (Your Name Goes Here) lol
    Be Blessed!

  • Imperative Ideas

    The intro to PHP course at Lynda is pretty good too. It's very beginner friendly.

    My favorite jQuery primer is at Webtuts but it kind of leaves you out to dry if you aren't getting something. Lynda moves slower but makes sure every step is well explained. Depending on your level of comfort with programming concepts, you may want to stick with the Lynda stuff for a while even if it's what you go to sleep to.

    --> Moving on

    I'll need the names of your custom post types as the critical variable will be post_type when you go to display a loop.

    Create a blank file called archive-posttype.php (replace posttype with the name of your post type) and drop this into it:

    <?php
    <?php get_header(); ?>
    
    -stuff-
    
    <?php get_footer(); ?>

    You may discover that this pulls your front page template instead of your content template. We'll worry about that later. You can do things like call a file called header_custompost.php by as <?php get_header('custompost') ?> that allows you to use a completely different page template for a specific post type.

    We're essentially going to take your header and footer then sandwich a code loop in the middle in order to create the index page. Replace "-stuff-" with this:

    <?php
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args = array(
    		'orderby'		=> 'post_date',
    		'order'			=> 'DESC',
    		'category'		=> '13',
    		'post_type'		=> 'post',
    		'post_status'		=> 'publish',
    		'posts_per_page'	=> 6,
    		'paged'			=> $paged,
    	);
    
    	$postslist = get_posts( $args );
    	foreach ($postslist as $post) :  setup_postdata($post);
    ?>

    Now replace "post" with the name of your custom post type.

    To start off, let's just do something really basic. Add this after your query:

    <div>
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <div><?php the_excerpt(); ?></div>
    </div>

    Now you should be able to visit http://yoursite.com/postname/ and see an index of your custom posts. They will use single.php by default (we can customize that display as well)

    Let me know how tangled up this gets you and we'll take things forward from there.

  • Imperative Ideas

    This page will walk you through the basics of creating a custom single-page for your custom post type display

    https://premium.wpmudev.org/blog/easy-guide-to-displaying-custom-post-types-in-your-wordpress-theme/

    Naturally, there is a lot more to it. This is pretty darn basic. Ultimately you'll want to name the template file single-posttype.php so that anything under your custom post type defaults to that style instead of having to be selected every time.

    Let's get the index done first though.

    You'll probably want to post a screenshot of how this thing should look and inform us a bit as to the class structure. I'll be as helpful as I can without actually doing the work for you.

  • Mark Wallace

    Hey Hey!

    I had a real world event this weekend. I just looked over the last two post. That tutorial by Sarah has encouraged me to try placing the CPT in the theme again, but it still leaves me with one question, that would probably be best answered before i start.

    I was using a CPT named "Pet" and i wanted say 60-100 thumbnails to display on each page with about 100 pages.

    So i created the CPT
    Baby then added categories like this
    + baby001
    + baby050
    + baby100

    My thought were i could then use gravity forms to select what entries went to what category, then use a page template for each category.

    Is there an easier way? Like being able to select the number that show at one time via pagination?

    Thought it would be wiser to ask then to assume!

    Thanks!
    Be Blessed!

  • Mark Wallace

    lol

    Why 100 categories?

    It is really one category, i am just trying to figure out how to limit each page from displaying more then 100 thumbnails, so may lack of experience with this lead me to think 100 categories 1 category for each page rather then 6,000 to a single category and all 6,000 thumbnails displaying on a page at once. That would be pretty hard on the servers.

    I figured there was a much simpler way, so i thought i would ask.

    I only created 2 CPT and 3 categories for each CPT for testing.

    Is there an easier way? Like being able to select the number that show at one time and use page pagination to separate the number of thumbnails that show?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.