Yes, I already knew the cause of what you’re experiencing:
The $page and $pages global variable have not been set up and a call to get_the_content
or get_the_excerpt
would return that error: count(pages)
That said, pages global variable is set to null, calling count(pages) triggers that error because a null value cannot be counted.
To fix this, one can easily tell that you’re calling get_the_content
or get_the_excerpt
outside the loop.
So you have to set up the post data correctly before usage, that’s what the loop is meant to do:
while ( have_post(): the_post() ) : // get_the_content() or get_the_excerpt() will work fine now the_content(); endwhile;
Related Posts:
- Illegal string offset Warning PHP
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- PHP contact form returns warning in text widget [closed]
- Warning: array_pop() expects parameter 1 to be array, boolean given
- Get rid of this Strict Standards warning [closed]
- Illegal string offset in PHP function
- Warning message (re. php) on the blog page
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- Error while setting role
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- I am receiving a pluggable.php warning sign on my only http:// page
- class ‘wphpc_PAnD’ not found
- PHP Warning: Missing argument 2
- Cannot modify header information – server cache
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- PHP warning with code for nav menu walker [duplicate]
- Warning: preg_replace(): Compilation failed: unknown option bit(s) set at offset -1
- Warning: Cannot modify header information
- Warning: Illegal string offset ‘post’ and ‘page’
- Trying to add taxonomy terms to search results page
- Illegal string offset Warning PHP
- start_lvl Ignored in Custom walker_nav_menu
- PHP Catchable fatal error: Object of class WP_Error could not be converted to string
- How to order WP_User_Query results to match the order of an array of user IDs?
- Add Adsense code in index.php
- How do I edit the php/html for a particular post?
- Make WordPress upload directory outside wordpress root with custom url
- Loading wordpress stuff on laravel site
- WordPress loop specific thumbnail size
- JavaScript, best way to use data from the loop
- Setting Up PHPUnit tests for WP development on Windows
- theme options echoing multiple times
- how to echo all tables that start with a prefix
- PHP can I add line numbers to file_get_contents()
- Prevent Indexing of 404 Page
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- write custom woocommerce templates and forms
- Custom location for attached images
- WordPress Search Results for Multiple Post Types
- Accessing data from a non-WP database/table within a page content
- WP Query with custom Shortcode
- How to display posts by current user in a drop down
- How to add a php custom page to WordPress
- Colon is Missing In My Website Url in WordPress
- How to register javascript variables in wp_localize_script?
- Commenting out unwated CSS/scripts in HTML with PHP
- How do I limit the number of forms a user can create in gravity forms?
- Creating sub-categories via php
- Add post with approval by the admin
- Widget back end radio button issue
- Troll the hackers by redirecting them
- Putting php inside an echo php shortcode
- GET problem in WordPress
- Almost Done… Post Format Code
- How to unserialize data from MySQL
- if ( ! function_exists
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Split site title and apply different classes
- Pass get data from anchor URL [closed]
- WordPress İmages Upload & Delete Error
- Shortcode for a Series of Elevating Image Files, Excluding a Range?
- Shortcode won’t execute
- Dynamic CSS through PHP issue
- posts_nav_link pulling in multiple post types
- Remove password protection from all posts
- security concerns if using html data-* attribute for l10n?
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Search bar for wp menu
- How to check a variable Changes
- Products listing check if meta checkbox is checked
- Check if user had autologin & if so, logout
- White screen after migrating site, but wp-admin works fine. Disabling all plugins, applying default theme and enabling debug mode does nothing
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- How do I change the “login” label in My Account page to “Registered Customer”
- Edit a function to take different actions based on user role
- How to have different headers.php files based on the display page
- Customize the “Available for back order” text for specific variation
- How to add custom attribute to all outofstock and all instock products automatically?
- Site infected by link
- sessionStorage saves input value in browser but it is not loaded in the form field
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- How to create an Email Subscription input in WordPress?
- autocomplete in wordpress using ajax with json-data
- wp-login.php?redirect_to=https problem
- Fatal Error cannot log into wordpress and website disappeared
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Updating custom user meta
- Trying send mail from Theme page
- How can I put a custom field as the link of a button shortcode?
- WordPress: Create A Widget to Accompany Plugin
- SHARING TO FACEBOOK – FROM DYNAMICALLY GENERATED PAGE
- Adding placeholder text field to woocommerce checkout [closed]
- Cannot modify header information – headers already sent
- Millennial Media PHP Setup ( Code Integration )
- Insert into db with foreach problem
- Add default block css when the block has been added with php?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- WordPress / PHP: Check if column has value and then check if value in array