| @@ -6,11 +6,16 @@ | ||
| 6 | 6 | 'orderby' => 'menu_order', |
| 7 | 7 | 'order' => 'desc' |
| 8 | 8 | ); |
| 9 | 9 | |
| 10 | +// The link is only shown on the settings screen; skip the query on the frontend. | |
| 10 | 11 | $topic_permalink = ''; |
| 11 | -foreach (get_posts($args) as $post) { | |
| 12 | - $topic_permalink = get_permalink($post->ID); | |
| 12 | +if ( is_admin() ) { | |
| 13 | + $args['fields'] = 'ids'; | |
| 14 | + $args['no_found_rows'] = true; | |
| 15 | + foreach ( get_posts( $args ) as $latest_topic_id ) { | |
| 16 | + $topic_permalink = get_permalink( $latest_topic_id ); | |
| 17 | + } | |
| 13 | 18 | } |
| 14 | 19 | |
| 15 | 20 | $forum_url = admin_url('customize.php?url=') . site_url('/') . get_option('_bbp_root_slug') . '?autofocus[panel]=forumax-settings&autofocus[section]=forum-archive-page'; |
| 16 | 21 | $topic_url = admin_url('customize.php?url=') . $topic_permalink . '?autofocus[panel]=forumax-settings&autofocus[section]=topics_fields'; |