• Resolved wpbccwnc5

    (@wpbccwnc5)


    On my events calendar page, I’m seeing this error in the web browser tab instead of the correct page title (Club Events Calendar):

    <br /> <b>Notice</b>: Object of class WP_Post could not be converted to int in
    <b>/home/bccwnc5/public_html/wp-content/themes/twentytwelve/functions.php</b> on line <b>249</b><br />

    Web page:
    https://www.bccwnc.org/events-calendar-page/

    Using Twenty Twelve theme version 2.5

    Here are Lines 248, 249, 250 from twenty twelve functions.php file:
    // Add a page number if necessary.
    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    $title = “$title $sep ” . sprintf( __( ‘Page %s’, ‘twentytwelve’ ), max( $paged, $page ) );

    All of the other pages on my website do NOT show this error.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello,

    This seems to a theme issue because the error is pointing you on your themes functions.php, I would suggest checking the functions.php around line 249.

    Thread Starter wpbccwnc5

    (@wpbccwnc5)

    In my original message, I copied these lines from the functions.php file:

    Here are Lines 248, 249, 250 from twenty twelve functions.php file:
    // Add a page number if necessary.
    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    $title = “$title $sep ” . sprintf( __( ‘Page %s’, ‘twentytwelve’ ), max( $paged, $page ) );

    Clearly the problem is there. The original error message points to line 249 specifically.

    However, I don’t understand what change is needed.

    Your functions.php is not the original anymore. The original lines 248-250 are this:

    * @param string $mce_css CSS path to load in TinyMCE.
    * @return string Filtered CSS path.
    */

    The lines you are referring to are originally 292-294.

    The original, complete function which contains the code you are referring to is:

    function twentytwelve_wp_title( $title, $sep ) {
    	global $paged, $page;
    
    	if ( is_feed() )
    		return $title;
    
    	// Add the site name.
    	$title .= get_bloginfo( 'name', 'display' );
    
    	// Add the site description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		$title = "$title $sep $site_description";
    
    	// Add a page number if necessary.
    	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
    		$title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) );
    
    	return $title;
    }
    add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );
    

    Please check if that is indeed your complete function as well.

    Since the problem is the title, have you tried changing the title, update the post and check it again? 🙂

    Thread Starter wpbccwnc5

    (@wpbccwnc5)

    I downloaded a zip file of the twenty twelve theme. Then I replaced my website’s twenty twelve functions.php file with the downloaded (default) file. No change, same error still happens.

    The Page in question is my Events Calendar Page
    Events Manager Options:
    Pages | Event List/Archives | Events page
    I’ve selected a page named Club Events Calendar
    That page was created back in February and its title has not been changed.

    I will ask again:
    did you change the title to test it?

    Please change the tile, so that WordPress can recreate it.

    Thread Starter wpbccwnc5

    (@wpbccwnc5)

    I’ve just changed the page title. The error still happens.

    Thread Starter wpbccwnc5

    (@wpbccwnc5)

    I’ve just created a brand new Events page and assigned it in the Events Manager Pro settings (pulldown menu) as the Events page – Pages | Event List/Archives | Events page
    I still have the same error when viewing this new Events page.
    Object of class WP_Post could not be converted to int

    Thread Starter wpbccwnc5

    (@wpbccwnc5)

    I’ve found a workaround to the problem. It’s only a workaround and not a true solution.
    I’ve edited the twentytwelve theme functions.php file.
    Remarked out three lines. These lines show as lines 249-251 when viewing functions.php in Visual Studio Code. This is in the // Add a page number if necessary section of functions.php.
    // if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    // $title = “$title $sep ” . sprintf( __( ‘Page %s’, ‘twentytwelve’ ), max( $paged, $page ) );
    // }

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Object of class WP_Post could not be converted to int’ is closed to new replies.