• Resolved dionysos73

    (@dionysos73)


    Hi,

    First, thanks for that incredible plugin. It’s really usefull and powerfull.

    I have a problem to display some post on a custom post type page. Each users have a page to display some information about their shop. Include sales and news. I have create two posts categories: sales and news. I want to display thoses articles for each page use by shops owners (i hope i’m clear with these explanations). With a condition if there no sales or news.

    So, inside the template i use this code for sales

    <?php
    $sales_shop = '
    [if type=post category=sales author=same]
     [field title]
     [content]
    [else]No sales!
    [/if]
    ';
    echo do_shortcode ($sales_shop);
    ?>

    But it doesn’t work, it display “No sales!” instead of the two posts i have create. Of course, i don’t want to display the same sales information for a shop owner A and a shop owner B.

    I have tried to use a related shortcode to display post of the author (i use Custom Content Shortcode with ACF), it works, but i can’t use it on a condition.

    Could you help me please, i’m pretty lost.

    Thanks a lot.

    https://ww.wp.xz.cn/plugins/custom-content-shortcode/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    Hello,

    The author parameter should be: author=this. Hopefully that will solve it.

    There are also a couple helper functions you could use:

    <?php start_short(); ?>
    
    [if type=post category=sales author=this]
     [field title]
     [content]
    [else]No sales!
    [/if]
    
    <?php end_short(); ?>

    In the next update I’ll add some documentation about shortcode use in a PHP template.

    Thread Starter dionysos73

    (@dionysos73)

    Thanks Eliot for this tip with start_short(), end_short().

    Unfortunately, the condition doesn’t work with author=this neither.

    Is it possible to add an option to related shortcode if there nothing to display ? (no related post, taxonomy, category, ect…).

    Thanks alot

    Thread Starter dionysos73

    (@dionysos73)

    Hi again,

    i have solve my problem with that:

    [loop type=post category=sales author=same]
    [field title]
    [content]
    [if empty]Nothing ![/if]
    [/loop]

    Thanks for your help and continue to excellent work 🙂

    Cheers…

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem to display post author’ is closed to new replies.