Replace category link with link to first post
-
I thought others might like this modification, which adds the option to replace the category menu link with the URL of the first post in that category. If the category is empty, it is removed from the menu.
Insert this at line 205 after ‘case “never”: ….. break;’
case "link to first": if (empty($posts)) { $inc += -1; } else { $menu_item->url = wp_setup_nav_menu_item( $posts[0] )->url; array_push($result,$menu_item); $menu_item_parent = $menu_item->db_id; } break;
Insert this at (new) line 448 after ‘<option value=”never”>…</option>’:
<option value="link to first" <?php selected( get_post_meta($item_id, "cpcm-remove-original-item", true), "link to first" ) ?>><?php _e('Link to first post'); ?></option>
https://www.ads-software.com/plugins/category-posts-in-custom-menu/
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- The topic ‘Replace category link with link to first post’ is closed to new replies.