How to do set post permalinks using 6 digit random unique function?
How to do set post permalinks using 6 digit random unique function?
How to do set post permalinks using 6 digit random unique function?
I think the best way to approach this might be to run your WP_Query just one time, but then access the stored query results three times to output each wanted set of data. This will save you from using multiple DB queries, and by using three separate loops, you can still add a parent div … Read more
Search results posts_orderby and ID
Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
Whatever is building the write screen for you to post on the frontend may be including the Categories on the screen, and adding them to $_POST, but your CPTs still must be registered to use them. I assume the Articles CPT had this, and you may have missed that step in creating yours. Check you … Read more
I would hook that on publish_post, so you aren’t messing with drafts, etc. And you need to account for multiple categories, and count the number of posts in each, and delete anything over 10. Perhaps something like this will get you in the right direction. May need some tweaking, mostly untested. function on_post_publish( $ID, $post … Read more
Short answer “no”, using globals is never a best practice, indicates that you might be trying to do something in the wrong place, and should be left as a last resort. In your snippet for example you have no idea who set the $post, was it set in the loop or outside it, was it … Read more
What you see in the edit post columns is controlled by manage_posts_columns filter. By playlist_id i assume you are looking for the post_id (since you mentioned playlists are simply custom post types). You can do so by using this code in your theme’s functions.php file: if ( !function_exists(‘add_playlist_id_to_column’) && function_exists(‘add_theme_support’) ) { // Add our … Read more
What hook do you use to update a post?
I suggest you use the pre_get_posts action hook provided by WordPress. Then, in your functions.php add the following code below: function custom_pre_get_posts($query) { // validate if(!is_admin() && $query->is_main_query()) { if(is_archive()) { $query->set(‘orderby’, ‘title’); // order posts by title $query->set(‘order’, ‘ASC’); // and in ascending order } } } add_action(‘pre_get_posts’, ‘custom_pre_get_posts’); You can learn more about … Read more