this should explain enough:
http://www.w3schools.com/php/php_if_else.asp
if you get stuck with php functions for instance, use web search:
in this case searching (googling) for ‘php if else’ would give the above link, and many more.
i find that w3schools are general are good source of reliable and short information.
Hey, thanks but I’ve already tried looking up if else on the net. This is the code I’m using.
<?php
if (function_exists('wp_pagenavi')) {
wp_pagenavi();
} else {
echo "Custom Text If Navigation Does Not Exist";
}
?>
I see nothing wrong with the code and on the homepage the navigation is displayed, but on anywhere else the custom text is not displayed, nothing is. I think the problem maybe that it’s looking to see if the function exists in general, not on that page. So on a content page it finds that the function does exist but can’t display it because it doesn’t exist for that page. Does that make sense?. The function exists, but it is not used on any page other than the homepage.
I think this maybe what’s happening, or the code is just completely wrong?, but if it was badly formatted then my site wouldn’t display, nevermind the navigation.
your if/else logic is ok.
pagenavi only exists on a page of posts (usually index.php) – to go from paginated post page to the next (if you have more posts than fit onto one page).
it is otherwise done by ‘next_posts_link()’ and ‘previous_posts_link()’ or ‘posts_nav_link()’. wp_pagenavi checks for the plugin.
on a ‘page’ page you won’t have pagenavi (the word might be misleading). (you might have ‘wp_link_pages’ in the page template, to navigate if the page is spread over separate pages by inserting <!--nextpage-->.)
and on single.php you may find ‘next_post_link()’ and ‘previous_post_link()’.
you will find the description all in the codex.
I see, I was thinking it may be calling the plugin rather than the codex. I still don’t understand why the code above doesn’t work though. It displays the page navi correctly on index.php where it is wanted, but the else statement doesn’t seem to work. Whenever I go onto any other page nothing is displayed at all. I would expect the text to be displayed because the page navi function does not exist for that page, but it does not echo back the custom text. Nothing is displayed after index.php. I don’t understand why this happens.
Thanks