Show prev and next post links for parent post of current image in attachment page?
Show prev and next post links for parent post of current image in attachment page?
Show prev and next post links for parent post of current image in attachment page?
You have to modify the query that selects the posts to select by month. This bit of code placed in the template will get the page number and subtract that from the current month. <?php $page = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; $subtractor = $page-1; $date = date(“Y-m-d H:i:s”); $current_month = date(‘n’, strtotime($date.’-‘.$subtractor.’months’)); $current_year = … Read more
only just use echo and get_ <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $i = 0; while ($my_query->have_posts()) : $my_query->the_post(); if($i % 2 == 0) { ?> <div class=”row”><?php } ?> <div class=”col-md-6″> <div class=”overview”> <!– Post details here –> … Read more
You need to send a custom query to get a list of posts. In this example we use a custom post type “project” and a custom taxonomy “sphere” and we get 1 next project in current sphere. In your use case you can increase posts_per_page to 4. <?php //remember the id and menu_order from current … Read more
<?php next_post_link(‘format’, ‘link’, ‘in_same_cat’, ‘excluded_categories’); ?> <?php previous_post_link($format, $link, $in_same_cat = false, $excluded_categories=””); ?>
Add following custom functions in functions.php file and instead of calling previous_post_link and next_post_link functions call custom_next_post_link and custom_previous_post_link custom functions respectively. function custom_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories=””, $previous = true ) { if ( $previous && is_attachment() ) $post = get_post( get_post()->post_parent ); else $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); if … Read more
prev and next_post_link ultimately call the get_adjacent_post function to query the db, which has filterable $join $where and $sort vars.
Here’s the code for what you’re trying to do (accessing post custom value): <?php global $post; $prev_post = get_adjacent_post(); $next_post = get_adjacent_post( false, ”, false ); $prev_post_id = $prev_post->ID; $next_post_id = $next_post->ID; // this should, according to your code above, be the http://example.com/your/img.jpg string $prev_img_path = get_post_custom_values( ‘your_key_name’, $prev_post_id ); $next_img_path = get_post_custom_values( ‘your_key_name’, $next_post_id … Read more
“Inside the Loop” essentially means that function relies on data from global variables (such as $post) that are set up when Loop runs. Note that this is not necessarily done by main Loop of query_posts(). In your specific code those variables are filled by $custom_posts->the_post() calls and after that wp_reset_query() gets those values back to … Read more
Did you try with: get_adjacent_post ? get_adjacent_post(false, ‘YourID’, false); wp topic: get_adjacent_posts-exclude-category-syntax