• Resolved digital_mercenary

    (@andersandersahlencom)


    Hi,
    I have tried using the shortcode in a php template together with do_shortcode.
    As in:
    <?php echo do_shortcode('[aw_year_links cat="26" postslug="nyheter"]'); ?>

    But it outputs ‘The are no posts in this category’.
    I guess the aw_year_links shortcode can not be used with do_shortcode?
    Or is there maybe a workaround?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter digital_mercenary

    (@andersandersahlencom)

    Upon further investigation I discovered that the issue I’m having is the same as in this post, meaning the links are rendered only when I’m logged in:
    https://www.ads-software.com/support/topic/output-only-works-when-logged-in/

    I am very curious as to how you solved the issue in that instance.

    Plugin Author AndyWarren

    (@awarren)

    Hello. Using the shortcode with do_shortcode() will absolutely work. “The are no posts in this category” is not a message being output by the plugin, but WordPress or your theme most likely. The plugin is running a WP_query() loop for the category specified, and if there are not posts in the category that message is likely what you’ll get.

    I don’t know of any reason why it would only work while logged in, and unfortunately I don’t recall how I resolved that other support request as it was over two years ago. If you would like me to take a look, please provide an admin login by email it to me here.

    Thread Starter digital_mercenary

    (@andersandersahlencom)

    Strange. I just emailed you all the login info.
    I so appreciate any help you can provide.

    Plugin Author AndyWarren

    (@awarren)

    I’m checking into this now. I’ll post again when I know something.

    Plugin Author AndyWarren

    (@awarren)

    I’m having a little trouble navigating your site as it’s in Swedish, and I don’t know Swedish. Can you please give me the URLs to the two pages you have the shortcodes on? There should be a shortcode to display the yearly category links, and a second page that contains the shortcode to display the posts from that year and category.

    Thread Starter digital_mercenary

    (@andersandersahlencom)

    Yes, this is the page I am using the shortcode on for aw_year_links:
    https://sunestrom.se/startsida-ny/

    This is the page with the Archives:
    https://sunestrom.se/nyheter/

    Arkiv = Archive, but I guess that’s kind of obvioous ??

    Plugin Author AndyWarren

    (@awarren)

    I don’t see the shortcodes on that page. Also, there are two shortcodes that need to be used.

    The first shortcode is [aw_year_links cat="X" postslug="slug-to-post-or-page"], which is used to build and display the year links.

    The second shortcode is [aw_show_posts cat="X" readmore="Continue Reading" publishedon="n/j/Y"], which is used to display the post content after click a year link.

    The plugin will not work correctly without both shortcodes set up appropriately. Each shortcode needs the same category number, and the first shortcode needs the page slug that the second shortcode is on.

    Plugin Author AndyWarren

    (@awarren)

    I need to take over the two pages you’re in if you would like me to investigate this further.

    Thread Starter digital_mercenary

    (@andersandersahlencom)

    Sorry, my bad.
    The shortcode on https://sunestrom.se/startsida-ny/ is included in the template themes/sunestrom/partials/section/news.php
    <?php echo do_shortcode(‘[aw_year_links cat=”26″ postslug=”nyheter”]’); ?>

    Thread Starter digital_mercenary

    (@andersandersahlencom)

    And yes, feel free to take over the page and make any changes as you see fit.

    Plugin Author AndyWarren

    (@awarren)

    I just emailed you a question to you. I am able to reproduce your issue with not seeing the links when you are logged in. I can’t get to your theme template file via the WordPress theme editor due to it being in a directory and not root level. Please read and respond to my private email.

    Plugin Author AndyWarren

    (@awarren)

    Just to close the loop here, after investigating the code in your site, it looks like a bug of some sort in my plugin with $postTypes = get_post_types( '', 'names' ); which is used in the function for both shortcodes the plugin uses. If logged out of WordPress the code is returning an empty array, so no links or posts are “gotten”.

    I’ll work on a fix and issue a plugin update soon. I’m marking this as resolved as I resolved it local to your install. Re-open if any other issues arise.

    Thread Starter digital_mercenary

    (@andersandersahlencom)

    You are a true superhero!
    Your commitment to resolve this and the quick turnaround on actually fixing it makes my jaw drop in awe.
    I am utterly grateful for your help, you shine like a diamond.

    Plugin Author AndyWarren

    (@awarren)

    I have updated the plugin to version 1.2.8. This includes the fix to the get_post_types() issue in this thread.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Using aw_year_links with do_shortcode not possible?’ is closed to new replies.