Multiple authors for single post without plugin

No need to apologize, and not a basic question actually. Depending on what you actually need to achieve once you have your multiple authors assigned, there are several ways to do it: Using tags or equivalent custom taxonomy If you just need to display “authorship” for any given post, you could create a custom non-hierarchical … Read more

Limit function to specific post category

You should check for category posts to modify content. Specify category ID (integer), name or slug (string), or an array of these in in_category check. function my_image_tag( $html, $id , $alt, $title ) { if ( in_category( ‘1’ ) ) { $html = “<div class=”my-class”>” . $html . “</div>”; } return $html; } add_filter( ‘get_image_tag’, … Read more

Fetch posts from current week (Sunday to Saturday)

You can try: ‘date_query’ => array( array( ‘year’ => date( ‘Y’ ), ‘week’ => strftime( ‘%U’ ), ), ), where %U is: Week number of the given year, starting with the first Sunday as the first week or ‘date_query’ => array( array( ‘after’ => strtotime( ‘last Sunday’ ), ), ),

Redirect before post page

The determination to redirect needs to be made prior to headers being sent to the browser. Otherwise you risk PHP warnings (i.e. errors) when the page is rendered. This makes the timing of the use of wp_redirect() incorrect in the other answers. (The function is right, it’s just used incorrectly.) If you are going to … Read more

if custom post type exist

You typed “mobiles” when you said you wanted to check for post type “mobile”. So simply remove the s ;). <? if( post_type_exists( ‘mobiles’ ) ) { echo ‘The Products post type exists’;} ?> Should be: <? if( post_type_exists( ‘mobile’ ) ) { echo ‘The Mobile post type exists’;} ?> If it’s still not working, … Read more

Edit menu item title from edit page/post

Whenever you add a new item to WordPress Menu ( Appearance -> Menu ) it creates a new Post of Post Type nav_menu_item and gets assigned a post meta called _menu_item_object_id with the main Post ID. For example, if I create a page called “Home” it gets assigned a Post ID of 2. Now, when … Read more