Loop to get current parent page “content” and his children content

Super basic example that gets the parents title and content and then the title and content for each child page. This is not just the loop, but an entire page template. <?php include_once( ‘header.php’ ); ?> <?php $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array(‘post_type’ => ‘page’)); ?> <?php if ( have_posts() ) : while ( … Read more

Display same menu for parent and all its children

Yes, create 3 custom menus and use a conditional. Example you have 3 custom menus named, Products, Services,Training. Open the section of the page you want to insert code in the header.php or where ever you need it. file and use: if (is_page( array( 42, ‘Products’ ) )) { wp_nav_menu(‘menu’ => ‘Products’); }elseif(is_page( array( 2, … Read more

Post-upgrade problems: Image URL in DB, but not showing

I don’t have time to produce working code for this. I will edit the answer if I get the chance. In the meantime, you probably want a filter on upload_dir to alter that path. Your code would look something like this then: function alter_upload_wpse_107016($upload) { remove_filter(‘upload_dir’,’alter_upload_wpse_107016′); // alter $upload array return $upload; } if (1 … Read more

How can I let users access a specific attachment?

WordPress (or more precisely its .htaccess or alternate web server configuration file) passes through requests to existing files. The easiest way would be to start at root of your site and (using FTP/SFTP/hosting admin panel/etc): create blank01 folder create blank02 subfolder in it place file.xml into subfolder And it should just work, link will point … Read more

Target Post Type from array Query

$my_query->post_type refers to the post type of the query (in this case an array), and not the results. (Its recommended to use $my_query->get(‘post_type’) too, but anyway…). To get the current post’s (in the loop) post type: $post_type = get_post_type(); You can also use that function outside the loop by passing the post object / ID. … Read more