Home Forums WoodMart support forum Problem with blog

Problem with blog

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #114112

    ihor.youx
    Participant

    Hi!
    I use WooCommerce AJAX Products Filter PRO + WPML in your theme.
    In post page I get error PHP Catchable fatal error: Object of class WP_Error could not be converted to string in /wp-content/themes/woodmart/inc/template-tags.php on line 1160
    I comment this code and blog works. But problem withh categories, in site post have category Без рубрики(eng. Uncategoriezed), but in admin I set Блог(eng. Blog).
    I think problem with AJAX Products Filter PRO, because Blog works correctly when I deactiveted.
    But also all work correctly when I swith theme by twentynineteen.

    I print $cat(in Attachments), with your theme get_the_category return empty array.
    PS I print also without $post->ID
    Can you help me pls? AJAX Products Filter PRO is very important for me

    Attachments:
    You must be logged in to view attached files.
    #114129

    Artem Temos
    Keymaster

    Hi,

    Could you please test how it works now?

    #114150

    ihor.youx
    Participant

    The problem disappeared! Thank you )

    #114167

    Artem Temos
    Keymaster

    Great 🙂

    #117235

    ihor.youx
    Participant

    Hi!)
    This problem reappeared (
    And I dont now why…
    I activated 2 plugins Autoptimize, W3 Total Cache and updated theme, but when I deactiveted plugins the problem did not disappear.

    #117358

    Artem Temos
    Keymaster

    Hi,

    Try to edit the file woodmart/inc/template-tags.php and replace the following code

    if ($show_current == 0) $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);
    $cats = str_replace('<a', $link_before . '<a' . $link_attr, $cats);
    $cats = str_replace('</a>', '</a>' . $link_after, $cats);
    if ($show_title == 0) $cats = preg_replace('/ title="(.*?)"/', '', $cats);
    echo wp_kses_post( $cats );

    with this one

    if ( !is_wp_error($cats) ) {
    	if ($show_current == 0) $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);
    	$cats = str_replace('<a', $link_before . '<a' . $link_attr, $cats);
    	$cats = str_replace('</a>', '</a>' . $link_after, $cats);
    	if ($show_title == 0) $cats = preg_replace('/ title="(.*?)"/', '', $cats);
    	echo wp_kses_post( $cats );
    }

    Regards

    #117603

    ihor.youx
    Participant

    Hi, its works, but incorrect category displayed

    #117647

    Artem Temos
    Keymaster

    Yes, because some of the plugin influence this functionality and our theme display what is stored in the database.

    #117661

    ihor.youx
    Participant

    It’s strange, the yoast plugin defines the category correctly.
    Replaced this
    $cat = get_the_category(); $cat = $cat[0];
    with
    $cat = get_post_meta($post->ID, '_yoast_wpseo_primary_category', true);

    #117668

    Artem Temos
    Keymaster

    But the first code should work since it is a native WordPress function.

Viewing 10 posts - 1 through 10 (of 10 total)