Support

Account

Forum Replies Created

  • Thanks well I was just going to post and your were faster than me šŸ˜€ I made a very silly mistake: instead of this:
    $superficie = $group['superficie_o_potencia'];

    I should had been:
    $superficie = $group['superficie'];

    I’m afraid I was too quick assuming things..

    Nevertheless, I confirm using get_queried_object does work just fine as well, and may use it in the future, thank you so much!!

  • Excellent works perfectly, thank you so much!!!

  • I forgot to add I’m trying to use a second value for “get_field(‘region’),” which should be an “or relation” if region is “online” or “learning center”.
    currently have this:

    <?php
            $today = current_time('Y-m-d');
            $args = array (
                  'meta_query'             => array(
                    'relation'    => 'AND',
                    array(
                      'category'         => 'events',
                        'key'       => 'end_date',
                        'value'     => $today,
                        'compare'   => '>=',
                        'type'      => 'DATE',
                        ),
                    array(
                        'key'   => 'region',
                        'value'   => get_field('region'),
                        'compare' => '='
                        ),
    
                    
                ),
                'meta_key'               => 'start_date',
                'orderby'                => 'meta_value',
                'order'                  => 'DSC',
                'posts_per_page' => 6,
                'category_name'         => 'events',
                'paged'         => 1,
    
            );
  • Tried and this time Google returned an error in addition to not displaying the image.
    If you check here and click where it says “2 warnings” in orange you will see that the url of the image is correct (when using my original settings) so I’m puzzled.
    https://search.google.com/test/rich-results?id=aFTfkfEm_IJkVbMMTmUaMg

  • Thank you for the answer!! So is not easy to edit/modify the plugin..
    Just in case is relevant there’s another plugin that’s a bootstrap carosuel with a bit more options. Here’s the link: https://wordpress.org/support/plugin/cpt-bootstrap-carousel/
    Also already posted in both plugin forums..

  • Hi James!
    Yes that’s a way of solving it. Though I ended doing this.
    get_field('phone_number', 414 );
    where the number is the ID of the post, specifying it there is no need to depend on the loop to define the post.
    Thanks again!

  • It returns the url as well… Maybe the problem is not with the line but with the code in the custom rss template (maybe the excerpt strips the img tag?)
    Here’s the code:

    <item>
                            <title><?php the_title_rss();?>, <?php the_field(region); ?></title>
                            <link><?php the_permalink_rss(); ?></link>
                            <pubDate><?php the_field(fecha_de_inicio); ?></pubDate>
                            <guid isPermaLink="false"><?php the_guid(); ?></guid>
                            <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
                <?php if ( strlen( $post->post_content ) > 0 ) : ?>
                    <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
                <?php else : ?>
                    <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
                <?php endif; ?>
                
                            
                            <?php rss_enclosure(); ?>
                            <?php do_action('rss2_item'); ?>
                    </item>
  • 1) Checked..
    2) and 3) I’m testing it in the same loop the regular acf google map is.
    4) Checked that.

    Did some changes and it no longer returns the initial error but this one:
    “The Google Maps API server rejected your request. This API project is not authorized to use this API.”
    So maybe is as you pointed earlier the api ā€œGoogle Places API Web Serviceā€ is needed in addition.

  • Mmm that’s odd. The var_dump($map); returns”bool(false)”
    In case I’m doing a foolish error:

    Regards.

  • I mistaked as well in the beginning it returned the api error but later it returned that the q parameter is missing though it was included in the code. I’m sorry about that I edited the above post as well.

    Ok the dump returned
    string(48) “https://www.google.com/maps/embed/v1/place?key=0&#8221;

    Can you also make sure the proper map services are enabled on that key? It doesnā€™t say in the googleā€™s documentation, but i think you might also need to enable the ā€œGoogle Places API Web Serviceā€ in order to use the place search.

    Ok checking it…

  • I’m getting this error “The Google Maps API server rejected your request. Invalid request. Missing the ‘q’ parameter.”

    There seemed to be a missing “)” tried many combinations though I’m not sure I included it correctly..

    $src = esc_url(add_query_arg([
              'key' => MyKey,
              'q' => $map['address']], 'https://www.google.com/maps/embed/v1/place')); ?>

    Regards.

  • Thank you so much!!! Now it is working great!!!!
    There’s only a detail missing: If I have more than one post with the same category. For example two posts with the contact region value as Santiago, the two are displayed instead of only one. Each region has a category assigned to it while “Contact Data”” is the parent category of all of them.

    code I’m using:

    $news_cat_ID = get_cat_ID( 'Contact Data' ); 
        $news_query = new WP_Query( array(
        'posts_per_page' => -1,
        'cat'            => $news_cat_ID,
        'no_found_rows'       => true,
        'ignore_sticky_posts' => true,
        'meta_key'       => 'region_contacto',
        'orderby' => array( 'meta_value' => 'ASC', 'modified' => 'DESC' )
    ));
    ?>
    
    <?php while ( $news_query->have_posts() ) : $news_query->the_post() ?>

    Edit: deleted this line as well:
    $news_cats = get_categories( “parent=$news_cat_ID” );
    And added a bit more of info.

  • Okey it returns the following text:

    Contacto

    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (27) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    CopiapĆ³
    [email protected]
    [email protected]
    +56 989025280
    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (29) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    CuricĆ³
    CentroBudistaOtzerLingCuric%C%B
    [email protected]
    Subteniente Luis Cruz MartĆ­nez 812, Daya Center
    +56 982494947
    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (25) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    La Serena
    BudismoOtzerLingSerena
    [email protected]
    Puyehue 611, Alto PeƱuelas
    +56 994038436
    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (24) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    Santiago
    CentroBudistaOtzerLing
    [email protected]
    Pasaje Traiguen 2420, 7500000 Providencia
    +56 9997890
    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (22) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    Valdivia
    BudismoOtzerLingValdivia
    [email protected]
    BellaMente Valdivia, Carlos Anwandter 348
    +56 977802320
    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (28) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    VicuƱa
    OtzerlingVicuna
    [email protected]
    +56 965804128
    string(473) "SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (23) ) AND ( wp_postmeta.meta_key = 'region_contacto' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_modified DESC LIMIT 0, 1"
    ViƱa del Mar
    BudismoOtzerLingVRegion
    [email protected]
    3 Poniente 441 local 14-A (entre 5 y 6 Norte), 2520164
    +56 956188137
  • I’m sorry for the noobish question, how do I print it out?
    Is it in the debug mode?

    do you have other plugin that tries to modify the wp query?

    I think I don’t.

  • Okey I feel like I’m spaming the thread, even though the topic is set as solved can I get some hints.. thanks!

  • I’m afraid is not working.. wordpress is no longer loading!
    Questions: where do I set the custom field name?
    Oh and for the moment learning to create a plugin is beyond my learning scope right now..

    I have so far:

    function my_acf_prepare_field( $field ) {
      $field['readonly'] = true; // optionally make the field read-only
      if ( $field['Madrid'] ) { return $field; } // bail if field has a value already
      $for_user = 2;
      $current_user_id = (int)get_current_user_id();
      if ( $current_user_id != $for_user ) { return $field; } // bail if not specified user
      $ip = my_get_field_function();
      if ( $ip ) {
        $field['value'] = $ip;
      }
      return $field;
    }
    add_filter('acf/prepare_field/name=region', 'my_acf_prepare_field');
    
    // this functions gets the custom field value
    function my_get_field_function() {
      if ( !empty( $field] ) ) {
        $field_value = $field;
      } else if ( !empty( 'Madrid' ) ) {
        $field_value = 'Madrid';
      } else {}
      return $field_value;
    }
  • Ok I apologize for the late reply… what I don’t quite grasp is the function to get the ip adress. Here is the modified code I have so far:

    <?php
    function my_acf_prepare_field( $field ) {
      $field['readonly'] = true; // optionally make the field read-only
      if ( $field['value'] ) { return $field; } // bail if field has a value already
      $for_user = 2;
      $current_user_id = (int)get_current_user_id();
      if ( $current_user_id != $for_user ) { return $field; } // bail if not specified user
      $ip = my_get_field_function();
      if ( $ip ) {
        $field['value'] = $ip;
      }
      return $field;
    }
    add_filter('acf/prepare_field/key=HEREFIELDKEY', 'my_acf_prepare_field');
    
    // this functions gets the custom field value
    function my_get_field_function() {
      if ( !empty( $field] ) ) {
        $field_value = $field;
      } else if ( !empty( 'HEREFIELDVALUE' ) ) {
        $field_value = 'HEREFIELDVALUE';
      } else {
        $field_value = $_SERVER['REMOTE_ADDR'];
      }
      return $field_value;
    }
    ?>

    Where “2” is the user ID,
    HEREFIELDKEY is the field key,
    HEREFIELDVALUE is the field value intended to set for the user.
    Question whats the second “else” for (for the getting the ip adress part)?
    Oh and thanks for taking the time to guide me! I really hope I get to learn more php with this example and not just copy paste the code (though a part of me prefers that). Regards.

  • Another try based on
    https://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0/

    <?php
    $news_cat_ID = get_cat_ID( 'Datos de Contacto' ); 
    $news_cats   = get_categories( "parent=$news_cat_ID" );
    
        foreach ( $news_cats as $news_cat ) :
            $news_query = new WP_Query( array(
                'cat'                 => $news_cat->term_id,
                'posts_per_page'      => 1,
                'no_found_rows'       => true,
                'ignore_sticky_posts' => true,
                'meta_key'   => 'region_contacto',
                'orderby' => array( 'meta_value_num' => 'ASC', 'modified' => 'DESC' )
    
            ));
    ?>
    <?php while ( $news_query->have_posts() ) : $news_query->the_post() ?>

    Not sure what to try next..

  • Thank you for the answer! I’m afraid it is still not sorting correctly.. I’m getting elements in this order: 02.La Serena, 00. Santiago, 08.Valdivia, …

    Edit: Changed the value of the select field (Field Type) to only numbers like “00”, “01”, “02”, … and used meta_value_num instead of meta_value
    is not working still.

    Edit2: another option perhaps is to sort after the query? or maybe with a function?

  • I’m afraid I don’t have the skills/knowledge to modify that code but I will give it a shot if you guide me. Will give it a try tomorrow.

  • Thank you for the swift answer! I limited each author to only be able to post in a certain category with a plugin, so I would rather not use IP (which may change). Setting a Rule for the Field Group will affect all the other custom fields whithin that group? If so how can only one custom field be set as default and not editable?

  • Can you please share the solution? I’m having the same problem.. and the code used to make it work?

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