Jump to content
php.lv forumi
Sign in to follow this  

Wordpress - wp_list_pages() links are replaced with custom field value

Recommended 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;

  		 $title = get_field('marka') . ' | ' . get_field('modelis') . ' ' . $title;

  		 $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 attached a screen-shot so you could understand the situation better.

If link is broken, you can check screen-shot by following link below:



With best wishes,



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...