wp_list_pages() links are replaced with custom field values from custom posts
-
Hi guys!
So, basically I have built custom post type and I have added few custom fields by ACF plugin (for example – <product name>). In functions.php, where I am registering this custom post type, in arguments array, I have excluded all supported fields (title,editor,thumbnail etc.) so I could add my ACF custom fields and make custom post title from custom field values(for example – “My custom post title” is replaced with “<product name>”)I am using code below to change custom post title to custom field values:
/* Set post title from meta field */ function new_title($title) { global $post, $post_ID; if(get_field('auto_marka')){ $title = get_field('marka') . ' | ' . get_field('modelis') . ' ' . $title; } if(get_field('prece_nosaukums')){ $title = get_field('prece_nosaukums') . ' | ' . get_field('modelis') . ' ' . $title; } return $title; } add_filter('the_title', 'new_title');
The problem is that, when I am trying to search for products in search page, all the navigation menu’s links are replaced with first custom post search result’s title (For example: “Home” is replaced with – <product name>Home)
Below is navigation menu code, that is used in search.php:
<?php if ( has_nav_menu( 'primary-menu', 'mytheme' ) ) { ?> <?php wp_nav_menu( array( 'container' => false, 'theme_location' => 'primary-menu', 'fallback_cb' => 'display_home', 'exclude' => 'home' ) ); ?> <?php } else { ?> <?php wp_list_pages('title_li=&depth=4&sort_column=menu_order'); ?> <?php } ?>
I have big headaches with this, because I am trying to fix this problem for days, so I would really appreciate your help! :@
P.S.I have added a screen-shot below so you could understand the situation better.
https://img607.imageshack.us/img607/9383/98682975.png
With best wishes,
Ricards
- The topic ‘wp_list_pages() links are replaced with custom field values from custom posts’ is closed to new replies.