Editing Complex Pages in Visual Mode

One thing you could do is create page templates for complex pages and simply add the content through the editor, leave as little mark-up as possible in the editor. Another thing that might help is using the editor style (activated with add_editor_style() in functions.php) and defined in editor-style.css so the client has a better sense … Read more

Set page template automatically based on parent

On the admin side, you could update the meta data for the page-post_type programmatically: global $post; if ( ‘swiss_cheese’ === $post->post_parent AND is_admin() ) update_post_meta( $post->ID, ‘_wp_page_template’, ‘some_template.php’ ); On the visitor facing side, you can simply jump into template redirect: function wpse63267_template_include( $template ) { global $post; if ( ‘swiss_cheese’ === $post->post_parent ) { … Read more

Allow only new sub-pages to be created

you actually don’t need any ajax or server side action, simple see if the user has selected a parent page: add_action( ‘admin_head-post-new.php’, ‘publish_admin_hook_wpse_78690’ ); add_action( ‘admin_head-post.php’, ‘publish_admin_hook_wpse_78690’ ); function publish_admin_hook_wpse_78690() { global $current_screen; if( ‘page’ != $current_screen->post_type ) return; ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#publish’).click(function() { var parent_id = jQuery(‘#parent_id’).val(); if (parseInt(parent_id) > 0){ … Read more

How to add a new tab to page editor

I remembered that once I done this, yesterday I found where, but that code was… bad. So today I little improved it and I’m going to share. Before I want to explain what I do. First of all, there are 3 main things to do: Add the tab title beside the standard 2 Add something … Read more

Is it possible to manipulate the list of page templates?

The workhorse is WP_Theme::get_page_templates() (wrapped by the helper function get_page_templates()). If you check out the source, you’ll see: /** * Filter list of page templates for a theme. * * @since 3.9.0 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * * @param array $page_templates Array of page templates. Keys are … Read more

Custom Field in Featured image for A particular post

Note that there are additional input arguments available for the admin_post_thumbnail_html filter callback, namely $post->ID and $thumbnail_id: /** * Filters the admin post thumbnail HTML markup to return. * * @since 2.9.0 * @since 3.5.0 Added the `$post_id` parameter. * @since 4.6.0 Added the `$thumbnail_id` parameter. * * @param string $content Admin post thumbnail HTML … Read more

Skipping first 3 posts in wp query

For skipping the post just use offset parameter in wp_query. To display latest three post : <?php $latestpost = new WP_Query(‘order=asc&orderby=meta_value&meta_key=date&posts_per_page=3’); //Here add loop to display posts like while($latestpost->have_posts()) : $latestpost->the_post(); the_title(); the_content(); endwhile; wp_reset_query(); //After that skip three posts using offset $latestpost = new WP_Query(‘order=asc&orderby=meta_value&meta_key=date&posts_per_page=6&offset=3&paged=’ . $paged); the_title(); the_content(); endwhile; wp_reset_query(); ?> That’s it

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