Podmetač Mikado S2-LU70211 2,10m
Opis Podmetač Mikado S2-LU70211 2,10m
Moderni podmetač izrađen od visoko otpornih materijala.
Novost je upotreba metalnog spoja ručke i okvira podmetača.
Do tada proizvedeni plastični spojevi bili su najslabiji dio cijelog podmetača.
Sama ručka i okvir izrađeni su od ojačanog duraluminija, zahvaljujući čemu je cijeli podmetač iznimno lagan, a ipak vrlo otporan.
Cjelina je presvučena (pod visokim tlakom) specijalnom zaštitnom površinom.
Premaz ne daje podmetaču samo elegantan izgled, već istovremeno osigurava cijelu konstrukciju.
Ne upija vodu.
Step 1: Add a Custom Field to Your Pages
First, you need to add a custom field to the pages you want to exclude. For example, you can create a custom field named `exclude_from_list` and set its value to `1` for the pages you want to hide.Step 2: Add the Filter to Your theme’s functions.php File
Next, add the following code to your theme’s `functions.php` file. This code will fetch all pages that have the `exclude_from_list` custom field set to `1` and add their IDs to the exclusion list./** * Exclude pages from wp_list_pages based on a custom field value. * * @param array $exclude_array The current array of excluded page IDs. * @return array The modified array of excluded page IDs. */ function exclude_pages_by_custom_field( $exclude_array ) { // Query for pages with the custom field 'exclude_from_list' set to '1' $args = array( 'post_type' => 'page', 'meta_query' => array( array( 'key' => 'exclude_from_list', 'value' => '1', 'compare' => '=' ) ), 'fields' => 'ids', // Only get the IDs 'posts_per_page' => -1, // Get all matching pages ); $query = new WP_Query( $args ); if ( ! empty( $query->posts ) ) { // Merge the found IDs with the existing exclude array $exclude_array = array_merge( $exclude_array, $query->posts ); } return $exclude_array; } add_filter( 'wp_list_pages_excludes', 'exclude_pages_by_custom_field' ); How the Code Works
- `wp_list_pages_excludes` Filter: This filter is triggered whenever `wp_list_pages` is called. It passes an array of page IDs that are already set to be excluded.
- `WP_Query`: We use `WP_Query` to find all pages where the custom field `exclude_from_list` is equal to `1`.
- `fields => ids`: This argument ensures that the query only returns the IDs of the pages, which is more efficient than fetching the full post objects.
- `array_merge`: We merge the IDs found by our query with any IDs that might already be in the `$exclude_array` (e.g., IDs passed directly to the `exclude` parameter of `wp_list_pages`).
Usage
Once you’ve added the code, any page with the custom field `exclude_from_list` set to `1` will automatically be excluded from the output of `wp_list_pages`, regardless of where it is called in your theme.Conclusion
Using the `wp_list_pages_excludes` filter is a clean and efficient way to dynamically exclude pages from your navigation menus or page lists based on custom metadata. This approach is much more flexible than hardcoding page IDs, especially as your site grows. For more WordPress tips and tricks, check out our other tutorials! If you have any questions or need further assistance, feel free to leave a comment below. Happy coding! 🚀Further Reading
Opis je automatski preveden, ispričavamo se zbog grešaka u tekstu.
- Šifra proizvoda S2-LU70211
- Proizvođač Mikado
- Jamstvo 24 mjeseca
- Dužina mreže za ribolov: 2,10m
- Dimenzije glave: 62x72cm
- Transportna dužina: 87cm
- Broj dijelova: 2
- Tip podmetača: spinerski
CJENOVNA BOMBA