I am using a custom post type: FAQ, to create an ongoing page of FAQ items.

I have created a custom template: faq-template.php, to display the items.

I need to hook other elements into the bottom of this page and various other pages. (Genesis framework.)

The problem is that when I use is_page() to conditionally hook the other elements, it fails, but only on the custom page template, with a custom loop.

I have marked up the code in detail to explain the issue.

Here's the template code:

//Custom post type loop for FAQ:

function my_custom_loop() {

global $post;

$args = array(
    'post_type'      => 'faq',
    'posts_per_page' => 20,
    'post_status'    => 'publish',
    'orderby'       => 'menu_order' 

echo get_the_id(); //For testing. This successfully outputs the page ID: #19 at the top of the page template in question, so I know that Wordpress recognizes this page as #19.

global $wp_query;
$wp_query = new WP_Query( $args );
if ( have_posts() ) : 

   do_action ('genesis_before_entry_content');

    while ( have_posts() ) : the_post(); 



    echo do_shortcode("[accordion]");

    do_action( 'genesis_after_endwhile' );

    do_action ('genesis_after_entry_content'); //Hooking stuff here



add_action( 'genesis_loop', 'bmg_custom_loop' );
remove_action( 'genesis_loop', 'genesis_do_loop' );


Here are the conditionals and the content I am hooking, from functions.php:

//Hook some buttons into the bottom of certain pages:

add_action( 'genesis_after_entry_content', 'my_page_buttons',999); //Where to hook

function my_page_buttons()

 //FIRST put the buttons only on the last page of multi-page items that use <!--nextpage-->
// OR if not multi-page, then put it on singular pages:

global $multipage, $numpages, $page;
if ( $multipage && $page == $numpages || 1 !== $multipage ) { 

//NEXT put it on specific pages that meet the above condition.
//This is the part that fails for page ID #19 only, the FAQ page template.

   if ( is_page( array( //put the buttons on these pages
        //When I delete this conditional, the buttons appear fine on ALL pages, including #19
        19, // Why does the FAQ page does not accept it's page ID #19 with is_page()?
    ) ) )

    { //Here's the output:

<div class="button-row">
<a class="button" href="<?php echo get_permalink( 49 );?> ">BUTTON ONE</a> 
<a class="button" href="<?php echo get_permalink( 97 );?>">BUTTON TWO</a>


My question again: Why does is_page() fail as a conditional on my custom post type template?

I have looked at several other related topics but didn't find an answer: Why is custom template not seen as page with is_page()? Conditional tag is_page with a custom post type Custom page template how to check is_page from functions.php?

1 Answer 1


Doh... While writing up this question it suddenly became clear why it was not working:

I was hooking my buttons inside the loop and since my loop was not a single page item, get_the_id() would be getting the ID of each post in the loop, not the page that the posts were on.

All I had to do was hook after the loop:

add_action( 'genesis_after_loop', 'my_page_buttons');

I'm posting this just in case someone else has a similar issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.