Single file upload
You can just grab the first file in the $_FILES array. if ($_FILES) { return $FILES[0]; }
You can just grab the first file in the $_FILES array. if ($_FILES) { return $FILES[0]; }
http://codex.wordpress.org/Function_Reference/next_post_link#Text_As_Link.2C_Without_Post_Title.2C_Within_Same_Category in same category = true is the trick
is_single() returns TRUE or FALSE, not a string. Additionally, you can test for a specific post with is_single() function by putting the post slug into the function call: if ( is_single( ‘your-post-slug’ ) ) { # do something } If you want to test for the proper post type use: if ( is_singular() and ‘your-post-type’ … Read more
You need next_post_link and previous_post_link, not next_posts_link and previous_posts_link. See the plural on the last two? The ones with the ‘s’ are for archive pagination. The ones without it are for single post to post pagination.
Your best bet would probably be the Rewrite Endpoints API. The API allows you to create post URLs with endpoints like lorem.com/post/133/json/ or lorem.com/post/133/print/. You’ll find useful code examples in the link provided.
I found the actual answer in a stackoverflow question. Quoted from the answer: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => $paged ); $wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; ?> <!– then the pagination … Read more
Looks like you’re trying to display comments for a single post that has comments disabled. You should find if ( comments_open() ) statement just one line below. Paste your code there and it will work just fine: <?php if ( comments_open() ) : ?> <div class=”comments-link”> <?php comments_popup_link( ‘<span class=”leave-reply”>’ . __( ‘Leave a reply’, … Read more
When checking each template include, the single footer contained an error. To resolve this, i duplicated the code from the index footer and amended for the single template. Thank you for your replies.
If you want to get post custom meta for the page assigned as the site front page, use get_option( ‘page_on_front’ ), which will return that page’s ID. i.e. change this: get_post_meta(get_the_ID(), ‘_custom_css’, true) …to this: get_post_meta( get_option( ‘page_on_front’ ), ‘_custom_css’, true ) …on the site front page (is_front_page())
For a hierarchical post type, you can use $post->post_parent and get_permalink(), perhaps like so: <?php global $post; $parent_permalink = get_permalink( $post->post_parent ); ?> <a href=”https://wordpress.stackexchange.com/questions/99483/<?php echo $parent_permalink; ?>”>Parent Post</a>