If post does not exist, do something

If in your template you create a 404.php all not-found requests will be handled by this template file, and there you can put whatever you want. Just as example, in the 404.php file is possible to use something like (it’s just a draft): <?php get_header(); ?> <h3> <?php $slug = get_query_var(‘name’); if ( $slug ) … Read more

Select post from dropdown and add query args not working

Rename your <select> to something other than page_id. The problem is that page_id is already taken (and handled) by WordPress (as query var). This should do, for example: <?php if (isset($_GET[‘editevent’]) && true == $_GET[‘editevent’]) echo ‘Post ID: ‘.$_GET[‘my_page_id’]; ?> <form method=”GET” action=”#”> <select name=”my_page_id” id=”my_page_id” onchange=”this.form.submit()”> <?php $args = array( ‘posts_per_page’ => -1, ‘post_type’ … Read more

Search for pages with permalink

If I understand well (and I’m not sure) probably you need only the get_page_by_path function: $pagefoo = get_page_by_path(‘foo/page2’); $pagefoo variable contain post object for the page with slug ‘page2’ that is child of page with slug ‘foo’.

Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT

Note that category and post_tag are both taxonomies, and that they are taxonomies that, by default, are only supported by the post post type. You have created a custom post type, and have registered support for a custom taxonomy for it: books_taxonomy. Thus, it makes perfect sense that a query for posts with the books … Read more

Yet another get_posts() in explicitly defined order problem

Instead, you should use WP_Query Something like so: $specific_order_pages_query_args = array( ‘post_type’ => ‘page’, ‘post__in’ => $ids, ‘orderby’ => ‘post__in’ ); $specific_order_pages_query = new WP_Query( $specific_order_pages_query_args ); WP_Query’s order value post__in is a special value to order by the supplied post__in ID’s See more under Order in WP_Query http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

Exclude categories from homepage not longer working

I have no idea how this was ever working for you to begin with, but there’s really no need to use a custom page template for the blog posts index template. WordPress provides a template file to use: home.php. Easiest solution: Rename homepage.php as home.php and remove any custom template header comments Remove all query_posts() … Read more

List all pages including archive

Yep, this is definitely possible. Grab your post types and insert them in $post_types to loop through every one of them to manually generate the archives and posts: <?php // post types of your choice $post_types = array( ‘page’, ‘work’, ‘people’ ); $wp_cats = array(); foreach ( $post_types as $post_type ) { $pages = get_pages( … Read more

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