• Hi everyone,

    I know this question has been asked to death and beyond. I’m just not having any luck finding anything useful that works at all ='(

    I’ve tried so many different things, googled my fingers to the bone and still had no luck. I’ve been at it for hours now and it’s doing my head in.

    Thank you above and beyond for any help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • ummm.. whats the question again?

    Thread Starter seforoth

    (@seforoth)

    Question is in the title… “How-to get the page name in the functions file”

    Usually get_the_title() gets the title of the current post (or page). Is that what you mean by “page name”?

    ^ or he must have meant listing all pages.. thats by wp_list_pages or get_pages.. or he meant templates.. and that would be by $templates = wp_get_theme()->get_page_templates().. only specialized page templates can be greped by php loop on get_template_directory() maybe..
    right questions get right answers. 🙂

    Thread Starter seforoth

    (@seforoth)

    Nope.

    Getting either the page ID or page name in the theme’s functions file (functions.php)

    I’m not sure just what you are after either but this may be usefull
    <?php $page = get_page_by_title( 'Front page' ); ?>
    where “Front Page” is the name of the page.

    You may then want to pull data from the page e.g.

    <?php if ( get_the_post_thumbnail($page->ID) ) : ?>
    		<figure class="classname">
    			<?php echo get_the_post_thumbnail($page->ID); ?>
    		</figure><!-- .classname -->
    	<?php endif; ?>

    and or

    <article id="id name" >
    		<div class="classname">
    			<?php echo apply_filters('the_content', $page->post_content); ?>
    		</div><!-- .classname -->
    	</article><!-- #id name -->

    Thread Starter seforoth

    (@seforoth)

    Every WordPress theme comes with a functions.php file……. go through any of the default WordPress themes such as Twentytwelve, TwentyThirteen and you’ll find it.

    This is the file I want to get the current page ID or page Name.

    I find it rather frightful that you guys don’t know what a theme’s functions.php file is =S

    What is it that you are trying to do?

    Thread Starter seforoth

    (@seforoth)

    I need to run specific code depending on what page it is.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How-to get the page name in the functions file’ is closed to new replies.