New answers tagged

3

since WP 4.4.0, you can use this filter that allows you to change the arguments used in the original cpt registration. Add this to your functions.php file: add_filter( 'register_post_type_args', function( $args, $post_type ) { if( 'wyde_portfolio' === $post_type && is_array( $args ) ) $args['rewrite']['with_front'] = false; ...


0

Try to put your post slugs in an array for the post_name__in parameter: 'post_name__in' => [ 'berlin', 'frankfurt', 'munich', 'augsburg' ],


3

"best" greatly depends on context. guid is probably (with some debate about it) the best way to uniquely identify a post, but not all import/export plugins leave it alone without changes. ID is a good identifier if you do not care about import and export. Slug is problematic because they might be changed by the user. The best thing to do if you need to ...


0

Have you already looked at get_page_children? you need to pass the id of the child page and the $children_posts to it and it will return all childpages of it... what you need is: child-1->ID and an array with child-1, child-2 and so on


1

Actually you should skip the condition altogether - you don't need to worry about permissions or context here, you are merely saying: If WordPress, for whatever reason, is determining if a slug is bad: run my additional conditions Currently, if a theme/front-end plugin/REST API call was triggering the filter (i.e. insert/updating a post), your checks ...


0

I think I am late but as per new guidelines I found this is best possible solution // Set the arguments. For brevity of code, I will set only a few fields. $args = array( 'slug' => 'akismet', // or any plugin slug 'fields' => array( 'version' => true ) ); // Make request and extract plug-in ...



Top 50 recent answers are included