Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • @jketelaar

    OK, well.. now that we found the incompatibility… what to do?

    For sure… don’t stop using the tool if it’s needed.

    We certainly should let both developer’s know of the incompatibility. I will do that with the ACF developer, and perhaps you could reach out to the developer of The Events Calendar plugin.

    As for a workaround… I will edit this post later with what I discover. I’m not sure the depth of it, but if it’s a quick thing… I will offer a workaround. Talk soon!

    EDIT:

    I wasn’t able to duplicate the issue. See attached. I have ACF Pro installed, and the free version of The Events plugin. Is that the same setup you have? And… when you deactivated the Events plugin, all was good?

  • Hi Pietro,

    Yes… sorry to have thrown so many suggestions to you in my reply. I was just elaborating that there are plenty of choices.

    I took another look at your site… and see where you have the code.

    A simple approach would be to create a second field for the URL. This could be a text field or a URL field.

    Here is how you could modify the code to include the second field’s value:

    <?php if( get_field('paese', $this->post->ID) ) { ?>
    
    <div class="block-left"><a href="<?php the_field('collegamento', $this->post->ID); ?>"><?php the_field('paese', $this->post->ID); ?></a></div>
    
    <?php } ?>

    I hope that’s helpful and gets you closer to your goal. Let me know!

  • @papijo

    Hey.. sorry for the late reply. I guessed you might know where to put the code because your original question had a function in it. My apologies. It could go in either a custom plugin or in your theme’s functions file as you figured out. I like to use a custom plugin, that way… if ever switching themes… my functions remain. A great way to kick off a new plugin is to use a free plugin called Pluginception. It makes it very very simple to get started… within seconds in fact.

    As for your other statement… it looks like a user setting may be in future plans, just hasn’t found its way into the graphical interface yet. I can’t confirm that though. I’m happy though that you were able to find a reasonable workaround.

  • Ok I now have this which displays the category image and all the posts associated with the category beneath it `<?php $args = array (
    ‘orderby’ => ‘name’,
    ‘order’ => ‘ASC’,
    ‘hide_empty’ => true,
    );

    $terms = get_terms( ‘category’, $args );
    foreach ( $terms as $term ) {
    echo ‘<br />’;
    echo ” . ‘<img src=”‘ . get_field(‘category_image’, $term->taxonomy . ‘_’ . $term->term_id) . ‘”>’;
    $post_args = array (
    ‘category_name’ => $term->slug,
    ‘posts_per_page’ => ‘-1’,
    ‘no_found_rows’ => true
    );

    $query = new WP_Query( $post_args );

    while ( $query->have_posts() ) {
    $query->the_post(); ?>

    <br /><div class=”hidepost”><?php the_title(); ?></div>

    <?php }
    } ?>`

    What I now need is a way to show or hide the page links on a page by page basis.

    Anybody have any ideas how I might achieve this?

  • I’m not sure that I understand completely what you mean but if you’re talking about the main WP Admin menu on the left. This would be accomplished where you are adding those admin pages. If your using ACF to add options pages, then you would set the capability required to access the options page. When creating a custom post type or taxonomy, these functions also have capability settings that would be used.

    For standard WP admin pages you can try this https://www.wpmayor.com/how-to-remove-menu-items-in-admin-depending-on-user-role/

  • Welcome to the forum. This forum works on BBPress, honestly I don’t know if it offers the features you refer to or not, I don’t think it does. Although, I’m not very familiar with it nor am I the admin on this site.

    1) I’m here every day and if there are any spam topics I generally see them and remove them. There is only one “Admin” and that’s the developer of ACF.

    2) I’m pretty sure this feature is not available in BBPress, but I’m not sure.

    As you might expect, the developer is busy working on the plugin most of the time and he does not take a lot of time out to answer questions or manage this forum. With the number of topics started daily, if he did, well he wouldn’t have time for working on the plugin.

    There are a couple of us that work in the very limited capacity to watch over this forum and do our best to not let questions go unanswered for too long if we’re capable of answering them. Sometimes the questions are just beyond our ability to help. This forum is really a users helping users forum and we really do depend on other users jumping in when they have experience enough to help.

  • I have just found a similar problem in this forum discussion.
    The solution given by James @acf-support is the same as the one given by @keithlock.
    Interestingly, re my point #5 above is silverdarling’s remark:

    Good thing is that wysiwyg.php looks like its primed to go for adding wysiwyg height via admin interface.

    This is similar to gallery_height being “primed” for setting, but again WHY is this not working?

  • Well got a couple of bits of code sort of working:

    Firstly this one which may be good for development further:

    <?php if ( is_active_sidebar( 'sidebar-1' )  ) : ?>
    	<aside id="secondary" class="sidebar widget-area" role="complementary">
    		<?php dynamic_sidebar( 'sidebar-1' ); ?>
    			
    			<?php $terms = get_terms( 'category' );
     if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
         echo '<ul>';
         foreach ( $terms as $term ) {
           echo '<li>' . $term->name . ' - ' . '<img src="' . get_field('category_image', $term->taxonomy . '_' . $term->term_id) . '"></li>';
            
         }
         echo '</ul>';
    	 
     } ?>

    This retrieves the category image for each category. I can build on that because I could apply the category image into a div background. This would hide the category image if there are no links to show beneath if I apply the image into the div as a background and the div doesn’t have a height.

    I just don’t know how to pull the posts in that would appear beneath each category heading.

    Then there is this:

    <?php 
    
        $args = array( 
            'post_type' => 'page','posts_per_page' => -1
        );
    
        $query = new WP_Query($args);   
        $q = array();
    
        while ( $query->have_posts() ) { 
    
            $query->the_post(); 
            
            $a = '<a href="'. get_permalink() .'">' . get_the_title() .'</a>';
    
            $categories = get_the_category();
    
            foreach ( $categories as $key=>$category ) {
    			
                $b = '<a href="' . get_category_link( $category ) . '">' . $category->name . '</a>';    
    
            }
    
            $q[$b][] = $a; // Create an array with the category names and post titles
        }
    
        /* Restore original Post Data */
        wp_reset_postdata();
    
        foreach ($q as $key=>$values) {
            echo $key;
    
            echo '<ul>';
                foreach ($values as $value){
    				echo '<img src="';
    				the_field('category_image', 'category_4');
    				echo '">';
                    echo '<li>' . $value . '</li>';
                }
    		
            echo '</ul>';
        }
    
    ?>

    This lists a category image above each post. If you look at the code I am having to call a category id – the_field(‘category_image’, ‘category_4’);

    to get the image to display.

    This would mean the same category image would display for all categories which would be wrong. On the other hand this retrieves all posts and puts them under the correct category titles they should appear under.

    So if I could somehow combine the above two pieces of code I would be halfway there.

    Although I still have to find some way of choosing which pages display from each category under each heading in the sidebar. I was thinking perhaps set them all somehow as ‘false’ until chosen from each page in the admin from a custom field menu then set them as ‘true’ if chosen.

    Both examples of code can be viewed here:

    http://151.252.3.6/~lewishickeyplatf/wordpress/

    You will see Code 1 Example and Code 2 Example

    Code 1 being the first bit of code above and Code 2 being the second bit of code above.

  • Hi Keith and many thanks for your help which set me on the right track.
    1.- You did not say (because this is self-evident to advanced users) WHERE to put your code. I found out that it goes in one’s current WP theme functions.php file. Maybe somewhere else as well?

    2.- Your code works OK with the relevant gallery field ID.

    3.- For that code to work with all gallery fields one can change it to:

    <style type="text/css">
        .acf-gallery {
            height: 210px;
          }
        </style>

    4.- Now that—thanks to you—I understand how the Wrapper Attributes Class and ID work I thought I would refine your solution by creating a .galleryheight210 style in my functions.PHP file and would apply it in my gallery field’s Wrapper Attributes Class. Unfortunately this does not work, because the Wrapper’s style is not applied in the right DIV or rather is over-written later on.

    5.- There remains the question of my original attempt at a solution. In file advanced-custom-fields-pro\pro\fields\class-acf-field-gallery.php line 463 is this code:

    // set gallery height
    $height = acf_get_user_setting('gallery_height', 400);
    $height = max( $height, 200 ); // minimum height is 200
    $atts['style'] = "height:{$height}px";

    which seems to refer to a “user setting”. My question is: where in the ACF interface (or in one’s theme function.php) can we SET that user setting? If we cannot set it, what’s the use of getting it?

  • The file input uses the default file field for the browser. This will probably look different in every browser. The file field itself is not really customizable. To do this you need to use a combination of custom CSS and JavaScript. https://www.wpguru.com.au/wordpress-development-tips/add-custom-css-js-advanced-custom-fields-plugin/ there are also documents on this site for adding custom javascript https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/

    As far as custom styling you’ll need to look at some other examples, https://stackoverflow.com/questions/5813344/how-to-customize-input-type-file, https://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/, https://www.google.com/search?q=customize+file+select+field

  • Did you try using a URL field? Or a text field that you can use to enter a URL?

    You could also have a field that selects an existing category or page… and output the HTML as needed.

    There are a couple different ways to do it… you can choose a field that returns an Object that contains a label and URL… or have two separate fields for that Data for more flexibility. And you can add a 3rd field… a checkbox, asking if the link should open in a new Window..

    Lot of choices.

    Let me know if you need further help.

    p.s. Remember you could use code similar to below to build an anchor tag based on multiple fields:

    <a href="<?php echo get_field('url'); ?>" title="<?php echo get_field('url_title'); ?>"<?php echo get_field('url_new_window'); ?>><?php echo get_field('url_anchor_text'); ?></a>

    The ‘url_new_window’ field can output target=”_blank” (with a leading space if set to TRUE (or checked) )

  • Hi there…

    I ran into something similar before. The closest solution I found was: https://www.bobz.co/dynamically-populate-select-fields-choice-in-advanced-custom-fields/

    This requires JQuery if you don’t want to reload the page…
    You could try a Step 1, Step 2 process… where each Step saves to the DB.. then it’s easier to filter the list in the subsequent step by using ACF filters and PHP…

    It’s doable, but a very advanced topic. Hope that you get it sorted out.

    We might be able to help a piece at a time if you implement many of the steps, and run into any snags along the way.

  • Below is the test code I was playing with. I used variables rather than ACF fields, but you can swap them back out.

    Also… I used || for OR, && for AND, and ! for “not equal to”

    Also… in the last conditional where you check for “One single link”… that won’t trigger when it’s just link 3, because the condition is already met when you output “Link 1 and Link 2 OR Link 3”.

    If you would like to tell me your purpose for the code, I may be able to offer a better solution.

    <?php
    $link1 = '1';
    $link2 = '';
    $link3 = '';
    if ( $link1 && $link2 && $link3 ) {
    
    echo '<div class="red">';
        echo '<p>All 3 Links</p>';
    echo '</div>';
    
    } else if ( ( $link1 && $link2 ) || ( $link3 && !$link1 && !$link2 ) ) {
    
    echo '<div class="blue">';
        echo '<p>Link 1 and Link 2 OR Link 3</p>';
    echo '</div>';
    
    } else if ( $link2 && $link3 && !$link1 ) {
    
    echo '<div class="green">';
        echo '<p>Link 2 and Link 3 But not Link 1</p>';
    echo '</div>';
    
    } else if ( ( $link3 && !$link1 && !$link2 ) || ( !$link3 && !$link1 && $link2 ) || ( !$link3 && $link1 && !$link2 ) ) {
    
    echo '<div class="hotpink">';
        echo '<p>One single Link</p>';
    echo '</div>';
    
    }
    ?>
  • What you’re looking to do is quite complex.

    First of all, it is not possible to directly order posts by a term. What you need to do is to get all of the terms, loop through the terms and get all of the posts in each term based on the list of links on the page.

    That’s

    
    get categories
       each category
          get posts using "post__in" query where the post_in value is derived from the list of links
          if there are posts in the category
             get the category image and display
             each post
                show link
    

    helpful links https://wordpress.stackexchange.com/questions/142268/order-posts-by-category-name, https://www.google.com/search?q=order+posts+by+category&oq=order+posts+by+category

  • See the single-location.php section of this page https://www.advancedcustomfields.com/resources/querying-relationship-fields/

    the only differences will be post type and the meta key.

  • I don’t know what order they all fire, but, for example, acf/init fires during the WP init action. This is probably the earliest of them all. For the rest, most of them are called during the WP action or filter of the same name, like admin enqueue scripts, admin_head.

    During form processing, that is saving values, some of them will not be run at all, these include acf/prepare_field and acf/render_field. The first when is run before a field is rendered and the second is run to render the field. Since there’s no rendering of fields during the save process they would not be called.

    acf/load_field, acf/load_value, acf/validate_value, acf/update_value are all run on each field where the documentation mentions them. I do not believe that acf/load_value is called at all during form processing, saving of a value. The only exception to this would be if you have added an acf/save_post filter and you’re getting the values of the fields for some reason.

    acf/save_post is run after WP inserts or updates a post. This could also run after WP inserts or updates a term or user. This is also run when an options page is being saved, but since there is not WP object envolved here I wouldn’t be sure.

    As for the rest of them, I don’t know for sure. But they all involve specific fields and would only run when those fields are needed. I do know that validate attachment runs before update_value and that validate_value runs before update_value, but this only happens if for some reason the form did not validate during the AJAX request. validate_value also runs on each field during the AJAX validation request when no values are saved.

    Not sure this helped you at all or why you’re looking for the information. I have the vague cloud in my head of the order that things happen in WP and most of the actions/filters in ACF are tied to WP filters.

    This looks interesting https://wordpress.stackexchange.com/questions/162862/how-to-get-wordpress-hook-run-sequence/162863.

  • Hi @mikehermary

    Do you have a link where I could see it in action, so I could look at the source HTML?

    It feels like an HTML/CSS issue more than a WordPress/ACF issue but I will have a quick look.

    It works for me when I duplicate it… so it might be something more specific with your setup. Perhaps activating a different theme briefly to see if it’s the theme.. then go from there?

  • Hello.

    Awesome ACF has a couple different solutions for this. Some aren’t native WP plugins, but instead… code that resides on GitHub for you to include yourself.

    Feature requests to include things into the core of ACF can be submitted through the ACF ticket system. It’s difficult to know if this will make priority… it’s up to the sole developer 🙂

    Hope the existing solutions found on Awesome ACF can help you out!

  • Hi, I used your code but was having issues. I was able to solve it using:

    echo '<ul class="nav nav-pills" id="pills-tab" role="tablist">';
    
    		$child_repeater = get_field('section_two');
    
    		//$count=0;
    		//// first loop
    		foreach($child_repeater as $item) {
    
    		    $tab_title = $item['tab_heading'];
    
    		    $tab_id = str_replace(' ', '-', strtolower( $tab_title ) ); 
    
    		    if (!is_null($tab_title)) {
    		 
    			 	echo '<li class="nav-item"><a class="nav-link ';
    
    			 	if( !$count) {
    
    			     	echo 'active';
    
    			    } 
    
    			    echo  '" href="#pills-' . $tab_id . '" data-toggle="tab" id="pills-"' . $tab_id . '"  aria-controls="' . $tab_id . '"  aria-expanded="true">' . $tab_title . '</a></li>';
    
    			    $count++;
    		    }
    		}
    
    	echo '</ul>';
    
    echo '</div>';
    
    echo '<div class="tab-content col-12" id="pills-tabContent">';
    
    	$i=0;
    	// second loop
    	foreach($child_repeater as $item) {
    
    	    $tab_title = $item['tab_heading'];
    
    	    $tab_id = str_replace(' ', '-', strtolower( $tab_title ) );
    
    	    $image = $item['tab_image'];
    	    
    	    $content = $item['tab_content'];
    
    	    if (!is_null($content)) {
    
    		    echo '<div class="tab-pane fade ';
    		    if( !$i) {
    		     	echo 'show active';
    		    } 
    		    echo '" id="pills-' . $tab_id . '">';
    
    			    echo '<div class="card mb-3">';
    			    
    			    	echo '<img src="' . $image . '" alt="' . $tab_title . ' ">';
    
    			    	echo '<div class="card-body">';
    
    			    		echo  $content;
    
    			    	echo '</div>'; 
    
    			    echo '</div>'; 
    
    		    echo '</div>'; 
    
    		    $i++;
    		 }
    	}
  • Hi @mrspabs

    Below is some code cleaned up a bit. I am assuming that 2006 is your Post ID? You don’t need to pass that to sub fields of your repeater, but it doesn’t hurt.

    I just added an extra bit to the ‘while’ statement making sure to only loop 3 times. I created the iteration variable just above the while statement with a value of 0. I then increment that value at the end of the while. Hope this helps! Please mark this thread as resolved if so, otherwise please reply with more questions.

    <?php
    date_default_timezone_set( 'America/Los_Angeles' );
    $today = date( 'Ymd' );
    if ( have_rows( 'events', 37 ) ) {
    ?>
    <ul>
    <?php
      $i = 0;
      while ( have_rows( 'events', 37 ) && $i<4 ) {
        the_row();
        $expire = get_sub_field( 'expire_on' );
        if ( $expire > $today ) {
    ?>
    <li class="eventrow event<?php echo get_row_index(); ?>">
      <h3>
        <a target="_blank" href="<?php the_sub_field( 'events_link' ); ?>">
          <?php the_sub_field( 'events_title' ); ?>
        </a>
      </h3>
      <p>
        <?php the_sub_field( 'events_date' ); ?><br />
        <em><?php the_sub_field( 'events_location' ); ?></em>
      </p>
    </li>
    <?php
        }
        $i++;
      }
    ?>
    </ul>
    <?php
    }
    ?>

    p.s. Thanks for teaching me about the get_row_index() function!

  • This is my guess on order when creating/editing a post:

    • acf/input/admin_enqueue_scripts
    • acf/input/admin_head
    • acf/load_field
    • acf/load_value
    • acf/prepare_field
    • acf/render_field
    • acf/init
    • acf/input/form_data
    • acf/upload_prefilter
    • acf/validate_attachment
    • acf/update_value
    • acf/validate_value
    • acf/validate_save_post
    • acf/save_post
  • Perhaps something like the code below (change the ID)…

    Note: you can target it using a Field Key or custom CSS ID

    <?php
    /* START: Changes height of Gallery Field */
    function my_change_gallery_field_height() {
    ?>
    <style type="text/css">
      #acf-field_59aefd2fd922c {
        height: 210px;
      }
    </style>
    <?php
    }
    add_action('acf/input/admin_head', 'my_change_gallery_field_height');
    /* END: Changes height of Gallery Field */
    ?>

    Let me know if that does it for you, and kindly mark as resolved if so!

  • Hi @kikadesign

    Since you are outside the loop, you will have to also pass in the Post ID (using get_the_id()) when using: have_rows in the format:
    while ( have_rows('book_reviews', get_the_id()) ): the_row();

    However, with the above code… you cannot pass in the ID until after this line:
    while( $my_secondary_loop->have_posts() ): $my_secondary_loop->the_post();

    So… you will have to come up with different logic to check if there are any rows, and to wrap your unordered list, but I imagine this will get you on the right track.

    Please mark as resolved or feel free to ask more q’s if needed.. I will subscribe to this thread.

  • Hi @leanda

    Interesting case study for WordPress/ACF.

    What you described can definitely be done.

    You can create a Custom Post Type perhaps (or just add Custom Fields to the standard Post), and… during the “Save” process, you can intervene using the acf/save_post filter to do your calculations.

    If you would rather the Users not have to login, you can use front end forms as you mentioned. The guide to create Front End Forms with ACF is here.

    In addition, all the filtering desires you mentioned (top 3 scores, by-the-week, etc) can be accomplished with custom queries. See this doc here.

    If this is helpful, please mark as resolved, and then revisit if you run into anything each step of the way. Perhaps we could have separate threads for each topic as we help you out. Best of luck with your project! Props to giving us older folks a bonus 4k 😉

    Keith

  • Well – I sort of solved this, but I’m still curious as to how to parse the above string. To get around this I used…

    global $wpdb;
    
    	$query = "
    		SELECT DISTINCT post_name
    		FROM $wpdb->posts
    		WHERE post_title LIKE 'request_status'
    	";
    
    	$result = $wpdb->get_row($query, ARRAY_N);
    	$field_object = get_field_object($result[0]);
    	$status_array = $field_object['choices'];

    this gives an array of choices from the field object instead of trying to read them from the database

Viewing 25 results - 10,751 through 10,775 (of 21,318 total)