Add a specific page before featured pages
-
Thanks for this great theme and for all the support you guys provide! You are great!
Problem: I’d like my front page to display a specific page (page_id 205) above the featured pages and then (under the featured pages) the posts.
So my intended front page structure is: 1) page 205; 2) featured pages; 3) posts.
Now I’ve checked a lot of snippets (thanks they are great!) and other solutions. The best I was able to get from previous solutions is here below (I’m pretty new year…). The problem is that with the solution below I display not only page 205, but also the posts before the featured pages (while I’d like to have the posts under the featured pages). Can you provide any help? Thanks in any case!
add_action('__before_loop', 'my_home_page'); function my_home_page(){ if ( ! ( tc__f('__is_home') && 'posts' == get_option('show_on_front') ) ) return; $page_id='205'; // page id you wanna show on front above the blog. query_posts("page_id=${page_id}"); if ( have_posts() && !is_404() ) : while ( have_posts() ) : the_post(); do_action ('__before_article'); ?> <article <?php tc__f('__article_selectors') ?>> <?php do_action( '__loop' ); ?> </article> <?php do_action ('__after_article'); endwhile; wp_reset_query(); endif; ##end if have posts } //we hook the code on the wp_head hook, this way it will be executed before any html rendering. add_action ( 'wp_head' , 'move_my_fp'); function move_my_fp() { //we unhook the featured pages remove_action ( '__before_main_container', array( TC_featured_pages::$instance , 'tc_fp_block_display'), 10 ); //we re-hook the block. Check out the priority here : set to 0 to be the first in the list of different actions hooked to this hook add_action ( '__after_main_container', array( TC_featured_pages::$instance , 'tc_fp_block_display'), 0 ); }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add a specific page before featured pages’ is closed to new replies.