I’m guessing the problem is here:
$pg_name = apply_filters( 'the_title', $item->title, $item->ID );
$page_id = get_page_by_title( $pg_name );
$item_output .= '<a'. $attributes .' id="'.$page_id->ID.'">';
I don’t think this makes any sense:
- you have the item title and ID
- you’re filtering the title
- and then you’re trying to look up the page ID again by the new, modified title? Which in this case doesn’t exist.
I’d replace these three lines with just
$item_output .= '<a'. $attributes .' id="'. $item->ID .'">';
Unless you’re trying to do something specific here I’m not seeing?
If you do want to compute $pg_name like this then you can reuse it in the $item_output .=
line just after the comment that runs the same filter again.
Related Posts:
- Check if a menu is empty?
- How To Make Connection To WordPress Data Base In A Plugin?
- WordPress Template Engine?
- Walker class: Problems with understanding how walk() method can be called without error
- How to get the post count for the last x days filtering by categories
- Display only text to WordPress loop without loosing the text formatting
- How to create shortcodes that pull custom field data from general settings
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- How to display related posts from parent category
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- How do I get images (with a thumbnail preview) to show in search results?
- How do I translate this string – PHP syntax question
- Warning when using
- How to break down importing of feeds
- PHPCS: Strings should have translatable content
- How to override wp-admin styling
- WordPress shows registration link for non logged users
- How to get woocommerce cart content without an action?
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- How can I resolve the php notice “Constant EMPTY_TRASH_DAYS already defined”
- Use wp_get_recent_posts with search term
- multiple if statements [closed]
- Escape post image attachments added to template
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Bridging TinyMCE js and WordPress PHP?
- Echo URL of large version of Featured Image
- Get_avatar filter?
- Remove price from Woocommerce variable product dropdown menu
- WP dynamic featured image – Can’t get second featured image url
- Getting trackpacks/pingbacks for a post via wordpress?
- Why is my cookie not unsetting upon logout? [closed]
- Loop through categories and display posts title under each dropdown
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- How to remove role=”navigation” from all nav elements?
- How to change redirection route to a php page for making it only accessible by logged-in members?
- how to query a post based on previous page post ID
- How to use $_GET function WordPress backend
- How to set variable, pass it to a partial file and remove it after?
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- wp_dropdown_pages auto submit
- add_filter only for front office
- How to array only one key from another array
- Detecting if parent page has gallery
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Removing WordPress Footer -without access to PHP code?
- Form Submission Not Working In Custom Theme
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Delete or edit postmeta with specific meta_key?
- Concatenate Custom Field Value & HTML Value
- How do I properly code my footer? See example
- how to hide or disable some part in specify page
- Use of IF statement in Header file
- Kohana Frontend, WordPress Backend
- apply_filters with several different values?
- Advanced Query posts
- Triggering a timewall after X days
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- echo cutom css code to WordPress page template file ? is this safe?
- Contain multiple page templates in one PHP custom template file in WordPress?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- PHP `iconv` not working inside a WordPress site
- How to edit button permalink inside function.php using a child theme?
- How to make a “page-option” in WordPress
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I visualize the author’s post from the front end?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Elementor to custom wordpress page
- custom post type not showed with bootstrap 4 modal and template part
- Query to show average # of months all accounts with specific role have been active
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Use PHP to inject HTML into before page renders?
- Query doesn’t display text data with apostrophes
- WooCommerce Custom Tab with ACF Repeater Field
- My WP Website Shows HTTP ERROR 500
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- soap request in wordpress for a fedex pickup request [closed]
- Dynamically Create Posts Via XML File
- pages disable after wordpress update
- How to only fetch certain Tag ID’s
- Create server side text from wordpress page
- AdWords API with WP
- Add title and caption to thumbnail image on mouseover
- How to set a cookie based on a page Get variable?
- Editing the contents of just one div on a page from wordpress
- Postmeta not saving
- How to change the menu color
- Display latest 5 posts on homepage
- Display Current Time using shortcode
- Import js variables loaded via wp_localize_script() into js module without global scope connection