How to set post slug when using wp_insert_post();?
The parameter to insert a custom slug is: ‘post_name’ => ‘my-custom-slug’ Not post_slug as one would think! 🙂
The parameter to insert a custom slug is: ‘post_name’ => ‘my-custom-slug’ Not post_slug as one would think! 🙂
Here’s a way to support pagination titles of the form: <!–nextpage(.*?)?–> in a simlar way as the core supports <!–more(.*?)?–>. Here’s an example: <!–nextpage Planets –> Let’s talk about the Planets <!–nextpage Mercury –> Exotic Mercury <!–nextpage Venus–> Beautiful Venus <!–nextpage Earth –> Our Blue Earth <!–nextpage Mars –> The Red Planet with the output … Read more
I usually use this approach: wrong approach <?php query_posts( array( ‘category_name’ => ‘news’, ‘posts_per_page’ => 3, )); ?> <?php if( have_posts() ): while ( have_posts() ) : the_post(); ?> <?php the_excerpt(); ?> <?php endwhile; ?> <?php else : ?> <p><?php __(‘No News’); ?></p> <?php endif; ?> With the help of @swissspidy the correct way is … Read more
The first thing to do to implements such task is to be able to recognise which page an user can edit. There are different ways to do it. It could be a user meta, some configuration value… For the sake of this answer, I will assume that a function lile this exists: function wpse_user_can_edit( $user_id, … Read more
Go to Screen Options at the top, and change the number to something like 200. I don’t think it will survive much more than that.
Try with this: <?php echo get_the_title( $ID ); ?>
<?php // would echo post 7’s content up until the <!–more–> tag $post_7 = get_post(7); $excerpt = $post_7->post_excerpt; echo $excerpt; // would get post 12’s entire content after which you // can manipulate it with your own trimming preferences $post_12 = get_post(12); $trim_me = $post_12->post_content; my_trim_function( $trim_me ); ?>
I finally got it working, but not with the code in my question. I totally scrapped that whole idea and restarted going in a new direction. NOTE: If anyone is ever able to sort out the issues in my question, feel free to post an answer. Also, if you have any other solutions, feel free … Read more
When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The meta_key is _wp_page_template and the meta_value will be the page template You can simply make use of get_pages to retrieve all pages which have a meta_value of the specified template … Read more
Just in WordPress 4.9 there’s this bug: https://core.trac.wordpress.org/ticket/42573 causing the template files to only be rescanned once every hour. To fix (until they release a new WP version with this changed), download the patch on that bug ticket and make the changes from the patch to wp-includes/class-wp-theme.php. Hope this saves someone the 2 hours I … Read more