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

Search by Hyphen

One approach is to modify the exclusion prefix through the wp_query_search_exclusion_prefix filter that’s supported in WP 4.7+. See ticket #38099. Here’s an example how we can change it from – to e.g. !: add_filter( ‘wp_query_search_exclusion_prefix’, function( $prefix ) { return ‘!’; // adjust to your needs (default is -) } ); where we would use … Read more

using wp_update_post on save_post

The reason it’s going to be infinite is that every time you save the post, it’s calling change_year…which then calls wp_update_post … which fires the save_post filter. After some review and research, I’m thinking that you should probably avoid the save_post filter. Try using this filter: http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data It gives you really what you want. Here’s … Read more

How does filter the_posts work?

First thing, in your code you are using the_post hook but in your question you are asking about the_posts hook, which are two different things. the_posts gets called just after the posts have been selected from the database and it passes an array of $posts to your function, so you should use that. as for … Read more

Find the post an attachment is attached to

So, if you start with this: $all_images = get_posts( array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ) ); Then $all_images is an array of objects. Step through each one: foreach ( $all_images as $image ) {} Inside that foreach, you can use the normal parameters available to the $post object: $image->ID is the ID of … Read more

How to merge two or more WordPress posts?

The requirements you are describing require much more of an explanation than is really suitable here. A simple solution might be to mark the duplicate posts as duplicates via a meta box on the post screen. This meta box would have one input: A reference to another post. Check out this tutorial on how to … Read more

How to automatically generate a unique random slug

Use the function wp_unique_post_slug(). Do not reinvent the wheel, this one is quite tricky. Usage: $unique_slug = wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ); Then you can test if $slug === $unique_slug and generate a new one if the test fails. You can find the function in wp-includes/post.php. It ends with a filter ‘wp_unique_post_slug’, so … Read more

Can I force a metabox to be in one column?

If you want the meta box to appear below the content area, use the context parameter ‘normal’. See Function Reference/add meta box – Parameters. Initially, your meta box should only go to the side bar if the context parameter is set to ‘side’. As far as making it impossible for the user to drag it … Read more

Strategy for handling hierarchical pages with empty parent content

I am using two strategies here… 1) is simple redirection to first child (using menu order) page-redirect.php <?php /* * Template Name: Redirector * Description: Empty Holder (redirect page) */ $rp = new WP_Query(array( ‘post_parent’ => get_the_id(), ‘post_type’ => ‘page’, ‘order’ => ‘asc’, ‘orderby’ => ‘menu_order’ )); if ($rp->have_posts()) while ( $rp->have_posts() ) { $rp->the_post(); … Read more

How to schedule multiple posts while adding new

Here’s a sketch of another idea, where we create scheduling shortcuts to make it easier for the users: We can use the post_submitbox_misc_actions to add extra fields to the submit box: /** * Scheduling-Shortcuts fields. * * @see http://wordpress.stackexchange.com/a/168748/26350 */ add_action( ‘post_submitbox_misc_actions’, function() { if( ! current_user_can( ‘publish_posts’ ) ) return; ?> <div style=”padding: 2px … Read more

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