php code for image fetching

How to fetch the featured image in wordpress post[?] echo get_the_post_thumbnail( $post_id ); Or, inside a proper Loop, the_post_thumbnail(); But I have a feeling that there is information missing from the question. You aren’t using any Core functions and there is no explanation why, or reasons why not. For example, WP_Query would be far easier … Read more

Front end post or photo or both

I’ve made a similar form before, and it works whether it has a post or not. This form does not use wp_editor, but you can just modify the code to suit your need. add_action(‘wp_ajax_add_story’, ‘process_story_entry’); function process_story_entry() { global $current_user; if ( empty($_POST) || !wp_verify_nonce($_POST[$current_user->user_login],’add_story’) ) { echo ‘You targeted the right function, but sorry, … Read more

Get URL for featured image for posts? [closed]

The function to use would be: $url = get_the_post_thumbnail_url(); However, that’s not the most helpful for you right now, so we have a meta field with placeholders that you need to swap out for URLs before outputting. breaking that down we get these smaller steps: // grab the field // grab the URL // swap … Read more

wordpress featured image

The most simple form of the featured images (post thumbnails) looks like this: You need to have this piece of code in your functions.php file: add_theme_support( ‘post-thumbnails’ ); Then in the index.php, or any other template file you want to show the post thumb or featured images, you would add this: <?php the_post_thumbnail( ‘thumbnail’ ); … Read more

Carousel Hover Image

I figured it out!! I added this piece of jQuery: <script type=”text/javascript”> <!– $(function() { jQuery(“.photos a”).hover(function() { var offset = $(this).offset(); var id_post = $(this).attr(“id”); jQuery(“.hover”).find(“span[id=”+id_post+”]”).css(“left”, (offset.left-312)+”px”); jQuery(“.hover”).find(“span[id=”+id_post+”]”).show(); }, function() { jQuery(“.hover”).find(“span”).hide(); }) }); //–> </script> and added an additional loop: <div class=”hover”> <?php query_posts( ‘category_name=photos&posts_per_page=-1’ ); ?> <?php if ( have_posts() ) : … Read more