How to add a .php file to WordPress

What you can do is this: Put up.php in your active theme’s folder, and put this line at the top of your up.php file: <?php /* Template Name: Up */ ?> Create a page called Up in your WordPress Dashboard, then on the right side of the edit page screen, set the Template to ‘Up’. … Read more

How to Check if a Page Exists by URL?

You could make a list of paths to check… $page_paths = array( ‘analysis/firstNamelastName’, ‘exercise/firstNamelastName’ ); Then check if there’s a page object for each of the page paths. foreach( $page_paths as $page_path ) { echo ‘<code>’ . $page_path . ‘</code> ‘ . PHP_EOL; if( ! $page = get_page_by_path( $page_path ) ){ echo ‘Does not exist.’ … Read more

How can I reverse engineer a Permalink to Find the Page?

Addressing both your original question and the question implied by your comment … Finding the page ID Every post and page within WordPress is given an ID. By default, WordPress uses the ID in the link structure: http://www.example.com/?page=ID or http://www.example.com/?p=ID (for posts). You can change this to a more user-friendly structure called “pretty permalinks” that … Read more

The next_posts_link() works only with original $wp_query

next_posts_link and previous_posts_link use the global $wp_query. function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/link-template.php#L1523 That means you need to do something like this to get those to work correctly. $orig_query = $wp_query; $wp_query = new WP_Query($args); // the rest of your code $wp_query = $orig_query; If you are … Read more

Create a page without adding a page in the Database

To wit, this technically isn’t a ‘page’, however it’s a way to surface content using mod_rewrite. The goal here is to add a URI segment of foobar that will trigger a custom query, then include the specified template file. Add a rewrite rule: add_action(‘init’, ‘foo_add_rewrite_rule’); function foo_add_rewrite_rule(){ add_rewrite_rule(‘^foobar?’,’index.php?is_foobar_page=1&post_type=custom_post_type’,’top’); //Customize this query string – keep is_foobar_page=1 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)