Access the same page from multiple urls (wildcard)

You can use template_include, but before you hook to this filter you must do the following steps: Create page template. e.g: page-target.php <?php /** * Template Name: Page Target */ … Manually query the contents of target-page on page-target.php template, because the global $post will be referencing to your some-prefix-* page. (Optional): Edit and apply … Read more

Disable Attachment Pages Completely

You can filter default rewrite rules and remove those for attachments: function cleanup_default_rewrite_rules( $rules ) { foreach ( $rules as $regex => $query ) { if ( strpos( $regex, ‘attachment’ ) || strpos( $query, ‘attachment’ ) ) { unset( $rules[ $regex ] ); } } return $rules; } add_filter( ‘rewrite_rules_array’, ‘cleanup_default_rewrite_rules’ ); Don’t forget to … Read more

Proper way to get page content

Just to clarify: You mixed two things here. qTranslate stores the different languages in the same post. If you call get_content(), $post->content or an other direct query, you will get the whole content with all different languages from the database. What qTranslates do, it creates a filter-hook which is attached to the_content hook. If somebody … Read more

A way to automatically install pages on theme install?

I got similiar situation where I needed to add page on theme activation and set it as homepage automatically. Here’s how I did it: add_action(‘after_setup_theme’, ‘mytheme_setup’); function mytheme_setup(){ if(get_option(‘page_on_front’)==’0′ && get_option(‘show_on_front’)==’posts’){ // Create homepage $homepage = array( ‘post_type’ => ‘page’, ‘post_title’ => ‘Home’, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => 1 ); // Insert … Read more

Listing pages which uses specific template [duplicate]

You can do this with a WP_Query meta_query. The page template filename is stored in post meta under the key _wp_page_template: $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘_wp_page_template’, ‘value’ => ‘product.php’ ) ) ); $the_pages = new WP_Query( $args ); if( $the_pages->have_posts() ){ while( $the_pages->have_posts() ){ … Read more

Delete Associated Media Upon Page Deletion

How about this? It adapts an example on the get_posts() function reference page. function delete_post_media( $post_id ) { $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => $post_id ) ); foreach ( $attachments as $attachment ) { if ( false === wp_delete_attachment( $attachment->ID ) ) { // Log failure … Read more

Difference between an archive and a page listing posts

Archive Page An archive page is part of the WordPress Template Hierarchy, and is the template file WordPress uses to display the archive index list for a given post type. The custom post type archive template hierarchy is as follows: archive-{posttype}.php archive.php index.php WordPress uses the query parameters to output this page, and posts are … Read more

Get current menu_order

If you have the post with an $id: $thispost = get_post($id); $menu_order = $thispost->menu_order; WordPress itself does not provide a function to get the menu_order, so you have to query the post-Object. If you are outside the loop, you can use the above function, however inside the loop you could also achieve this by: global … Read more

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