• Resolved comsys13

    (@comsys13)


    I can not get widgets o show in my page.

    I have this content in page page [do_widget id=cart66cartwidget-4] also tried with simple text boxes) but they do not show

    Normal shortcodes work though.

    I had to fix the theme to support shortcodes myself though, so where it simply before posted the content the code is now

    $s = $post_content->post_content;
    $s = strip_shortcodes($s);
    echo $s;
    do_shortcode( get_the_content() );

    Can you guys see what i may be doing wrong since the widget does not show itself when shown this way? (The widget does work if e.g. put into the footer)

    https://www.ads-software.com/plugins/amr-shortcode-any-widget/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author anmari

    (@anmari)

    I’m sorry – that’s just awful code – what is it even doing ? I don’t mean to offend you it’s clear you are not a programmer.
    The first 3 lines bear no relation to the last.
    Why would you strip shortcodes when you trying to get them to work ???
    and do_shortcode is supposed to have a shortcode as a parameter not the content and one wouldn;t use it there like that.

    Try using just

    ‘the_content();’

    in the page template. THis should work IF nothing else has removed the filters or is messing with them – sometimes some shortcode plugins aren’t written properly wrt handling the content.

    https://developer.www.ads-software.com/reference/functions/the_content/

    If it does not work then temporarily switch to a wp default theme like twenty-sixteen and deactivate all other plugins. Refresh – it should then work.

    Then swop theme back, refresh. If doesn’t work, then your theme is the offender – post on the theme support site.

    If not the theme Then one by one reactivate the plugins, refreshing each time. Most likely you’ll work out which is the offender. Post on their page.

    https://webdesign.anmari.com/2932/debugging-a-possible-clash-between-plugins-andor-a-theme/

    Thread Starter comsys13

    (@comsys13)

    I see I made a typo trying things and posing at the same time. It was meant to be test code. But yes, I don’ spend my time in WordPress API at all, so I tried a few things from the net.

    The point is this:

    As stated, the theme did not process shortcodes at all. It basicly just output $post_content->post_content withou any processing of shortcodes.

    I then tried some things on the net and had the awful test code working so much that shortcodes for other plugins worked. I.e. I had content output. Shortcodes stripped from content. Shortcodes processed and shown at bottom. But yes, I don’ know WordPress API very well so I just tried a few things I found on the net and then decided to ask.

    Anyhow – thanks for your help (I actually think you may have pointed me in the right direction), even with the insult

    Thread Starter comsys13

    (@comsys13)

    In the end I solved it by using the WP PHP code the_widget(‘widgetxxx’);

    Plugin Author anmari

    (@anmari)

    excellent ! sounds like a much cleaner approach. sorry if the words above sounded harsh – must have got me on a frustrated day.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Weird case of theme and widget not working’ is closed to new replies.