This…
array('54'=>'Post #1','23'=>'Post #2', '654'=>'Post #3',)
… is not a string. It is an array definition.
All you need to do is create an array, which is what you want, and skip the string completely.
function post_page_options(){
$post_page_options = get_posts('category=orderby=title&order=asc&numberposts=");
foreach( $post_page_options as $value ) :
$str[$value->ID] = $value->post_title;
endforeach;
return $str;
}
Related Posts:
- Simple custom theme option not being saved
- remove_action on after_setup_theme not working from child theme
- How to load scripts/styles specific for a page
- Is there any global functions.php file which works for any theme?
- Child theme – Overriding ‘require_once’ in functions.php
- Display random categories on the front page (Finding and Editing Theme Functions)
- Issue with get_theme_mod returning a blank value instead of the saved value
- Hourly Routine Not Firing ( wp_schedule_event() )
- How to get an array of menu items from the toolbar?
- which is the function that removes accented vowels?
- How to save Uploaded image in custom option panel?
- How to add an export function to a custom Option Theme Page
- Theme Demo in live Site
- If function exists, and array is met, echo function?
- Customising widget titles/headings in WP 5.8
- get excerpt without images
- Child Theme Not Overriding Parent Theme
- Theme options WP Editor
- Where does function_exists() look to decide whether a function exists? [closed]
- Theme-Config tab in admin Pannel?
- When to use an if statement after get_posts?
- Is It wrong to use oop approach on functions.php?
- PHP files included in functions.php don’t seem to work
- Defining a global array in functions.php?
- How to manage arrays from custom functions stored in functions.php?
- How to remove howdy dropdown menu content
- get_post_type() in in_array doesn’t work for some reason
- Hook specific functions if on a specific admin page
- Set WordPress Default Template
- How can I change the do_action function in footer (copyright area)
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- functions.php mistakenly deleted
- Echo tags used to describe the theme
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- changing behaviour of get_search_form
- Child Theme files – what is needed?
- How to load jQuery in the footer – nothing works for me
- Problem only while using require_once() within functions.php
- Translation of theme using child theme
- Image rotation fails to regenerate custom sized thumbnail
- Sorting table function default
- How to stop twenty fifteen theme from cropping featured images?
- Theme functions.php file auto delete everyday [closed]
- How to remove style attribute in WordPress RSS output?
- Create a new query in function.php to filter blog posts
- WordPress website Rs changed to currency symbol
- show first 3 thumbnails of posts in different sizes [closed]
- Is there an alternative to get_template_directory_uri()?
- create filter in functions.php
- Add Custom Background Properties to Customizer
- Functions in custom theme
- Parse error after modifying the template menu [closed]
- Generating dynamic css into custom file [closed]
- WordPress PHP Conflicting User Sessions
- Option Tree integration of Custom CSS
- Function that outputs second theme url
- Not all CSS elements transferring via parent to child?
- unnecessary request call for js and css after calling wp_dequeue_script
- Get array of metakey in all posts
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Test if a post exists by category and date
- How to echo the value of an array element using a function via a shortcode
- Filter nav menu items HTML tags and wrap inner text with span
- issue with if/elseif in_array inside foreach loop display only one post
- Can’t switch to a child theme using filters template, option_template and option_stylesheet
- Show some menu sub items as dropdown under a menu item
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- $_Get and &_REQUEST Index Undefined on Functions.php
- Getting the teaser text without overriding global variables
- Default Nav Highlight
- call_user_func_array() expects parameter 1 to be a valid callback, function
- Adding theme option values as custom body class
- “options.php” not found
- How to use get_posts() function in functions.php
- How to override this theme function in child theme
- get_template_directory() – references parent theme directory
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- How do I preserve changes to a theme’s functions.php across updates?
- How to make sure relative URL works when site is not on root domain?
- Output comment_author in array
- What function actually renders the wp_admin_bar ? How can I call it?
- How to add or delete default value theme options while activate and deactivate theme
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Astra theme – cannot set short product description under the product title (product name)
- Override a Post’s URL with Advanced Custom Fields Function
- Header menu aligned right on all pages except for single-post page [closed]
- Class parameter in get_avatar args doesn’t get added to output
- CSS style and app.js not loading
- How to create an array if ’empty’?
- Exclude admins from query get posts
- Pass an argument into a function to extract from array
- Combine multiple menus using the filter wp_nav_menu_items
- Setting Up Child Theme To Take Priority
- Shortcode Initialization in a Custom Theme
- Featured image on archive page based on post type
- How can I stop the hook from breaking the login/logout function?
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- How to assign results to variables?
- Get title from IDs in a string