Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Jonathan Pak

    (@jjpak)

    Hi chetmac,

    thanks for answering.

    Indeed, I use Advanced Custom Fields.
    Does that ring a bell ?

    Amongst the other plugins worth mentionning, I use Elementor.

    Thread Starter Jonathan Pak

    (@jjpak)

    Good news :

    I found a solution.

    I don’t really know why,
    but it happened for some posts which were created by the WP Admin Panel.

    The issue didn’t occur for posts (of sfwd-lessons, whatever the post-type) which had been created through Zapier.

    So I tried deleting the disfunctionning posts and recreating them via a Php code snippet :

    ${post} = array(
      'post_title' => 'YOUR POST TITLE',
      'post_category' => array(85), /* Optional : Post category */
      'post_type'=>'sfwd-lessons', /* Optional : Post type */
      'post_status' => 'publish',
    );
    wp_insert_post($post);

    And the posts created this way work well with AirPress.

    Thread Starter Jonathan Pak

    (@jjpak)

    After further investigation,

    I found a recurring pattern.

    Please have a look at the names for which this error happens :

    • Perte de poids – Niveau 1 Femme – Jour 1
    • Perte de poids – Niveau 1 Femme – Jour 2
    • Perte de poids – Niveau 1 Femme – Jour 4
    • Perte de poids – Niveau 10 Femme – Jour 1
    • Perte de poids – Niveau 10 Femme – Jour 2
    • Perte de poids – Niveau 10 Femme – Jour 4
    • Perte de poids – Niveau 1 Homme – Jour 1
    • Perte de poids – Niveau 1 Homme – Jour 2

    Ok, just for the sake of clarification, in french :

    • Perte de poids means weight loss
    • Niveau means level
    • Jour means day
    • Femme means woman
    • Homme means man

    This doesn’t happen for any other combination of level and day.

    Only for those above.

    There seems to be something.

    I made sure that the name are absolutely identical both withing AirTable and WordPress. I checked, doubled checked.

    Would that give you any clue about what’s happening ?

    Regards,

    Jonathan

    This might be useful too if you have multiple fields to check :

    function hide_empty( $atts, $content = null ) {
    $values = shortcode_atts( array(
    ‘field’ => ”,
    ), $atts );

    echo do_shortcode( ‘[apr_populate field=”‘.$values[‘field’].'” relatedTo=”Exercices”]’ );
    $nom_exercice = do_shortcode( ‘[apr field=”‘.$values[‘field’].’|Nom de l\’exercice”]’ );

    if (empty($nom_exercice)) {
    $content=”;
    }
    return $content;
    }
    add_shortcode(‘hide_empty’, ‘hide_empty’);

    This creates an enclosing shortcode [hide_empty field=”YOUR FIELD”] YOUR CONTENT [/hide_empty]

    If “YOUR FIELD” is empty, then “YOUR CONTENT” won’t be displayed.

    Well it might not be the best way to do it, but once again it worked for me…

    Woops sorry,

    this wasn’t the right one.

    Here it is :

    function bloc_a( $attr, $content = null ) {

    $bloc_a = do_shortcode( ‘[apr field=”Bloc A”]’ );

    if (!empty($bloc_a)) {
    }
    else {
    $content=”;
    }
    return $content;
    }
    add_shortcode(‘bloc_a’, ‘bloc_a’);

    Add this to your function.php

    I’m no expert, but this worked anyway…

    Hi,

    I did something like this to hide or display part of the page :

    function hide_empty_bloc( $atts, $content = null ) {
    $values = shortcode_atts( array(
    ‘field’ => ”,
    ), $atts );

    $query = new AirpressQuery(“Séances”, “Exercices”);
    $query->filterByFormula(“{Nom de la séance}=’Perte de poids – Niveau 1 Femme – Jour 1′”);
    $nom = new AirpressCollection($query);
    $bloc_a = $nom[0][$values[‘field’]];

    if (!empty($bloc_a)) {
    }
    else {
    $content=”;
    }
    return $content;
    }
    add_shortcode(‘hide_empty_bloc’, ‘hide_empty_bloc’);

    How it works :

    • This creates an enclosing shortcode, in my case [bloc_a][/bloc_a]
    • if the field called “Bloc A” is empty, then nothing within the shortcode get displayed.

    Hope it might help.

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