I'm attempting to personalize a Wordpress theme. I've got a function in styles/functions.php that I must operate on some pages.
I have to be to:
- Identify the page ID to find out if the function should execute
- Pick which hook to add the function to (ideally something similar to page load.
functions.php is perfect for theme specific functions known as within your theme. If this sounds like a style specific function then your function call ought to be within the header (or wherever you would like the creation of the function to look) via
<?php my_function() ?>.
Hooks are for plug ins, not template specific code.
If you're within the Loop, you'll be able to call <?php the_ID() ?> as WarrenB stated. If you're outdoors from the loop, then <?php echo $publish->ID?> prints the page ID.
Towards the questions you posed, given you need to choose on id #9, run your loop such as this:
<?php query_posts('page_id=9') if (have_posts()) : while (have_posts()) : the_publish() // Do whatever on publish id #9 ?> <?php endwhile else: ?> // Do whatever on the rest of the posts <?php endif ?>
If the is not the solution you are searching for, please increase the information for your question.