WordPress.org

Forums

Problem with tags and fetured image. (12 posts)

  1. prince4747
    Member
    Posted 3 years ago #

    Hi,
    I made a blog in wordPress. My problem is, I want if user add a new post the the user have to add featured image and minimum 3 tags before publish. If he does not add tags and featured image then the post will not be publish just say a message about this.Can anyone help me in this issue.

  2. deepbevel
    Member
    Posted 3 years ago #

  3. prince4747
    Member
    Posted 3 years ago #

    Hi deepbevel,
    Thanks for your reply. when i add this plugin it show error.

  4. deepbevel
    Member
    Posted 3 years ago #

    try disabling other plugins. Also, it hasn't been updated for a year, may not be compatible with the latest version of wp,.

    I haven't been able to find another like it. However you could try to use custom fields, here's another plugin which may help.

    Also, maybe check out custom post types, pretty sure you can do that with custom posts. Not sure which method is best or easiest

  5. deepbevel
    Member
    Posted 3 years ago #

    I don't see that this custom fields plugin allows for a featured image, but it does allow for images. There's a way to display attached images like featured images, I can help with that if you need it.

  6. prince4747
    Member
    Posted 3 years ago #

    Yes,I need help. Can you please write details. I need it vary urgent.

    Thanks

  7. deepbevel
    Member
    Posted 3 years ago #

    This custom fields plugin seemed like it was going to be great but I find no documentation on how to get the fields to appear in the selected location. I selected a post category, but how can fields appear in a category which hasn't been selsected by the author yet? confusing..

    I can show you how to display attached images like featured images, but that won't solve the problem of making images required.

    I used the Quick Post Widget plugin which had required fields, including image. but the image was embedded in the post. Not sure if it would function like an attachment image.

  8. deepbevel
    Member
    Posted 3 years ago #

    okay, got the new required field to show up. I didn't realize it was part of a field group, and so I didn't name the group, which make it not appear!

    Anyway some good news, when the image is attched it functions like a gallery image. which means it's attached to the post. this means you can make the image function like a featured image, even though it's not.

    first, add a new function:

    function main_image() {
    $files = get_children('post_parent='.get_the_ID().'&post_type=attachment
    &post_mime_type=image&order=desc');
      if($files) :
        $keys = array_reverse(array_keys($files));
        $j=0;
        $num = $keys[$j];
        $image=wp_get_attachment_image($num,'large', true);
        $imagepieces = explode('"', $image);
        $imagepath = $imagepieces[1];
        $main=wp_get_attachment_url($num);
    		$template=get_template_directory();
    		$the_title=get_the_title();
        print "<img src='$main' alt='$the_title' class='frame' />";
      endif;
    
    }

    Then, you have to use this in place of the_post_thumbnail, where ever you want the first image attached to a post to appear when there is no featured image assigned.

    <?php if
    (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
    
    echo get_the_post_thumbnail($post->ID,'thumbnail');
    
    } else if
    
    ( (function_exists('main_image')) && (main_image())  ) {
    echo main_image(); } ?>
  9. deepbevel
    Member
    Posted 3 years ago #

    also, you'll have to use css to control the size of the main_image.

    in twentyten theme I did this:

    /* =Controls image size of main_image function
    -------------------------------------------------------------- */
    
    .frame
    {
    width: 25%;
    }
    /*--------------------------------------------------------------*/
  10. deepbevel
    Member
    Posted 3 years ago #

    haha this is very cool, I need this too. thanks for making me dig around!

  11. deepbevel
    Member
    Posted 3 years ago #

    tried it with a post instead of a page. It works! the image attachment is a required field once the apprppriate category is selected.
    Then, after implimenting the new function,
    the first image attachment for the post appears in the archive or blog page like a featured image.

    However, although the image is attached to the post, the image will not appear in the post without the doing the ussual "insert image" through the media uploader, or by using the [gallery] short code.

    Also, you'll have to make sure authors use the category which requires the image. Maybe another plugin which limits categories based on user role?

  12. deepbevel
    Member
    Posted 3 years ago #

    let me know how it's going, I'll help as I can. There's still more I want to do with this idea, having to do with limiting admin access based on user role. Also want to revisit (I've done it before) limiting specific user roles to specific categories for the reason mentioned above.
    I'll be working on a site for a 200 member art group soon and I want to find the simplest way for members to add galleries. A front end solutution would be ideal, but that could get messy fast.

Topic Closed

This topic has been closed to new replies.

About this Topic