kezzykezyqgc
Forum Replies Created
-
Forum: Plugins
In reply to: [Posts in Page] Show Pages and PostsI strung together my own fix combining some code from here with that from another website https://anartworkaccess.com/show-excerpt-of-child-pages-on-a-parent-page-with-a-shortcode/
So I put
function subpage_peek() { global $post; //query subpages $args = array( 'post_parent' => $post->ID, 'post_type' => 'page' ); $subpages = new WP_query($args); // create output if ($subpages->have_posts()) : $output = '<ul>'; while ($subpages->have_posts()) : $subpages->the_post(); $output .= '<h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2> <a href="'.get_permalink().'"> <p>'.get_the_post_thumbnail( $postid, array(180,9999), array('class' => 'alignleft') ).'</a>'.get_the_excerpt().'<br /> </p>'; endwhile; $output .= '</ul>'; else : $output = '<p>No subpages found.</p>'; endif; // reset the query wp_reset_postdata(); // return something return $output; } add_shortcode('subpage_peek', 'subpage_peek');
into the functions.php file, which let’s you post subpages on parent pages using the shortcode [subpage_peek}. I added the ability to show the featured image at the same size one of the posts for displaying the featured image as a post in page so you can go back and forth between them without losing formatting and I made sure the image links to the page. It doesn’t worth for categories or tags, but it works for what I needed at the moment. If anyone can figure out how to do it for tags/categories, please post here. Thanks!
Forum: Plugins
In reply to: [Posts in Page] Show Pages and PostsI’m thinking it has something to do with (page_posts.php):
protected function paginate_links( $posts ){ global $wp_query; $page_url = home_url( '/' . $wp_query->post->post_name . '/' ); $page = isset( $_GET['page'] ) ? $_GET['page'] : 1; $total_pages = $posts->max_num_pages; $per_page = $posts->query_vars['posts_per_page']; $curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0 ) ? $posts->query_vars['paged'] : 1; $prev = ( $curr_page && $curr_page > 1 ) ? '</p></p> <li><a href="'.$page_url.'?page='. ( $curr_page-1 ).'">Previous</a></li> <p><p>' : ''; $next = ( $curr_page && $curr_page < $total_pages ) ? '</p></p> <li><a href="'.$page_url.'?page='. ( $curr_page+1 ).'">Next</a></li> <p><p>' : ''; return '</p></p> <ul>' . $prev . $next . '</ul> <p><p>'; }
or (page_posts.php):
// get posts in a certain category by name (slug) if ( isset( $atts['category'] ) ) { $this->args['category_name'] = $atts['category']; } elseif ( isset( $atts['cats'] ) ) { // get posts in a certain category by id $this->args['cat'] = $atts['cats']; }