Check if the child page has sibling pages, and bookmark current page

Yes, it is possible: <?php global $post; $current_post = $post; if ( $post->post_parent ) { $siblings = new WP_Query( array( ‘post_type’ => ‘page’, ‘order’ => ‘ASC’, ‘post_parent’ => $post->post_parent ) ); } if ( $siblings->have_posts() ) : ?> <ul> <?php while ( $siblings->have_posts() ) : $siblings->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/306078/<?php the_permalink(); ?>”> <?php if ( $current_post->ID … Read more

How to create a page that shows the last 10 posts?

By default WordPress displays your content in a blog format on the homepage. Using Default Static and Blog Page Settings in WordPress. WordPress comes with built-in support for creating a custom home page (static front page), and a separate page for blog posts. To use this method, you need to create two new WordPress pages. … Read more

Output Post with ACF Fields into other Post

To not duplicate code you could make a file in your theme/child-theme for the html of the post which you intend to embed, let’s say x_cpt_render_html.php: function get_x_cpt_html(){ ?> <div class=”x-cpt”> <h2> <?php the_title(); ?> </h2> <div class=”content”> <?php the_content(); ?></div> <div class=”custom”> <?php the_field(‘custom’); ?> </div> </div><?php } Then you could embed this file … Read more

determine whether content is of type Page or a Post and display accordingly

The wordpress way solution is // put this in header.php var ajax_url =”<?php echo admin_url(‘admin-ajax.php’);?>” // in js file $(‘a:not([href^=”#”])[href]’).click(function(e) { e.preventDefault(); var $this = $(this); var lnk = $this.attr(‘href’); var jqxhr = $.post(ajax_url, {‘action’:’list_content’, url: lnk}); jqxhr.done(function(data) { if(data === ‘post’) { $.prettyPhoto.open(lnk + ‘?iframe=true&width=80%&height=80%’); } }); }); // functions.php add_action(‘wp_ajax_nopriv_list_content’, ‘list_content’); add_action(‘wp_ajax_list_content’, ‘list_content’); … Read more

Use same page-mypage.php template for several pages

To re-use the same template for different kinds of pages you can use the template_include filter. Example given from the docs: add_filter( ‘template_include’, ‘portfolio_page_template’, 99 ); function portfolio_page_template( $template ) { if ( is_page( ‘portfolio’ ) ) { $new_template = locate_template( array( ‘portfolio-page-template.php’ ) ); if ( !empty( $new_template ) ) { return $new_template; } … Read more