Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @markgdyr

    Thanks for the bug report.

    Looking at the file, the line in question is:

    
    $o['name'] = end(explode('/', $o['url']));
    

    Seems like WP’s new strict standards has an issue with the ‘/’ as a parameter?
    That’s pretty strange…

    Do you have debug mode on or off?

  • Sorry for speaking to myself. I have figured it out. I have done the following. Thanks again for your help @elliot

    <script type="text/javascript">
        
            jQuery(document).on('acf/setup_fields',function(e){
    		      //alert('test');
              jQuery( "#dialog" ).dialog();
    
        		
        	});
    
          </script>
  • Hi @elliot,

    thank you for your answer. I have already read this article, but I don’t reaklly understand it. Do I have to create the acfg/setup_fields action in my wordpress functions.php or directly into my HTML in the create_field function() ?

    My create_field function looks like this now. But it doesn’t work 🙁

    	function create_field( $field )
    	{
    		// defaults?
    		/*
    		$field = array_merge($this->defaults, $field);
    		*/
    
    		// perhaps use $field['preview_size'] to alter the markup?
    
    		// create Field HTML
    		?>
          <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
          
          <script>
            $(document).live('acf/setup_fields', function(e, div){
     
            	// div is the element with new html.
            	// on first load, this is the $('#poststuff')
            	// on adding a repeater row, this is the tr
             
            	$(div).find('.class').each(function(){
             
            		$(this).doIt();
             
            	});
             
            });
            
            function doIt() {
                alert("Hello World!");
            }
          </script>
          <div id="dialog" title="Basic dialog">
            <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
          </div>
    		<?php
    	}

    Cheers,
    javanese

  • On the off chance that someone else may be looking for this, here’s my solution.

    It checks whether the field exists, then outputs 10 RSS feed items including title and full content.

    <?php $blogfeed = get_post_meta($post->ID, ‘blog_feed’, true);
    if($blogfeed) : ?>
    
    <?php
    include_once(ABSPATH.WPINC.’/rss.php’); // path to include script
    $feed = fetch_rss($blogfeed); // specify feed url
    $items = array_slice($feed->items, 0, 10); // specify first and last item
    ?>
    
    <?php if (!empty($items)) : ?>
    <?php foreach ($items as $item) : ?>
    <div class=”feed-item”>
    <h4>” target=”_blank”><?php echo $item['title']; ?></h4>
    <p><?php echo $item['atom_content']; ?></p>
    </div>
    <?php endforeach; ?>
    
    <?php endif; ?>
  • Turns out it pulls up the feed just as I entered above, but it doesn’t quite work:

    – If I hard-code a URL, it pulls up the feed items info
    – but when I use ACF, it prints the feed URL and then gives an error:

    Warning: array_slice() expects parameter 1 to be array, null given in myfile.php

    It’s like it outputs the feed URL differently than a hardcoded one. get_field didn’t do anything at all.

    What’s the proper way to include feed URL in there so it would be processed as it should?

  • Hi @javanese

    It is important to place your jQuery code within the acf/setup_fields action.
    This ensures that all HTML is ready for jQuery

    You can read more in this guide:
    http://www.advancedcustomfields.com/resources/getting-started/adding-custom-javascript-jquery-for-fields/

  • Hi @gato_gordo

    Thanks for the request.

    Yes, it is quite easy to create a custom location rule. You can follow this guide to do so:

    http://www.advancedcustomfields.com/resources/tutorials/custom-location-rules/

    I’ll also add this request to the to-do as I would like to see it in the core over the next coming versions

    Thanks
    E

  • Hi @rdck

    Does your code contains an endif ?

    Perhaps it is not the query but a syntax error on the page?
    Can you turn on DEBUG MODE in your wp-config.php

    Thanks
    E

  • Hi @rainstorminc

    The problem with managing a plugin with over 1,000,000 downloads is there is always an issue with any code change! 🙂

    Sorry mate, but I would really like to leave the code as is and ask you to hook in and modify the 3rd party conflict yourself.

    Thanks for understanding
    E

  • Hi @kikimarie1234

    Thanks for the question. There’s a lot to take in here, and I wonder if some screenshots of the post_Type edit screens would help understand what is connected where.

    What is the issue you are having? Do you not know where to put the code?

    I think the solution is quite simple. You need to add the relationship code within you loops. Have you looked over the relationship field documentation code examples?

  • Hi @Deelite

    The select field is a simple dropdown input which allows the user to select from a pre-defined list of choices.

    It sounds like you want a select list for the list of countries.

    Then you will need to create another select field which will display the retailers. This choices for this select list should be left blank.

    You will then need to hook into the acf/load_filed filter and populate the ‘retailers’ select list choices based on the value selected by the first select box.

    This is not possible out of the box and will require some PHP, jQuery and AJAX functionality.

    Good luck

  • Hi @customaniac

    This would be best left as a tag taxonomy.

    This will also allow you to perform powerful taxonomy queries.

    Are you able to use a custom taxonomy?

  • Hi @Koli14

    Have you looked at the HTML source that this PHP produces? I believe your textarea will have a name like this:

    
    fields[field_key]text
    

    but what you want is:

    
    fields[field_key][text]
    

    Adding the extra square brackets will allow the data to be correctly posted

  • Hi @funack

    I am yet to find a solution for this.

    As discussed in the old support thread:

    Term meta is stored in the wp_options table (as there is no ‘default’ meta table for terms). Each option_name is prefixed with the taxonomy name + term_id

    Like this:

    category_2_image => 123

    I don’t think it is possible to perform a meta query due to the way data is stored.

    Perhaps you could look at another term_meta solution?

  • Assuming you’re using this in the ‘register_field_group()’ function? What is your field group setting(s)? Is the data saving to the database correctly?

    EDIT: I think I read your question wrong (or too quickly).

    ACF won’t automatically recognize a custom save_format – you’ll have to add this in yourself via a custom field type. I would take a look at the textarea field class and modify the ‘format_value_for_api()’ method (in your custom field type class).

  • Hi Elliot,

    Thanks for your reply.

    While I understand your position, it seems as though the specific request is actually a tighter implementation of the search and shouldn’t negatively effect anyone since, as you said, it’s locked in with the IDs and is just returning posts that are within the user-specified settings.

    Do you foresee a problem that someone might encounter with this update that I might be missing?

    Thanks!

    -Matt

  • +1! This is exactly the kind of feature I requested on the old forum. Such a front-end filter would be immensely useful.

  • oh yes, sorry… the filter call needs to be changed and the post type in the filter callback need to changed – in fact there is a bit where I commented out the post in the original – here is some changed code with comments as I can’t test it fully without setting up a new site for posts and creating users etc..

    function posts_for_current_author($query) {
    	
    	if( !$query->is_admin )
    		return $query;
    		
    	if( isset($query->query_vars['post_type']) &&  $query->query_vars['post_type'] == 'acf' )
    {
    	return $query;
    }
    		
    	
    	if( !current_user_can( 'moderate_comments' ) ) {
    		global $user_ID;
    		$query->set('author', $user_ID );
    
                    // filter for changing the numbers on the list
                    // its called for views_edit-xxx where xxx is the post/custom post type
    		add_filter('views_edit-post', 'fix_post_counts');
                    add_filter('views_upload', 'fix_media_counts');
    	}
    	return $query;
    }
    
    add_action('pre_get_posts', 'posts_for_current_author');
    
    // Fix post counts
    function fix_post_counts($views) {
        global $current_user, $wp_query;
    	
    	
    	
        unset($views['mine']);
        $types = array(
            array( 'status' =>  NULL ),
            array( 'status' => 'publish' ),
            array( 'status' => 'draft' ),
            array( 'status' => 'pending' ),
            array( 'status' => 'trash' )
        );
        foreach( $types as $type ) {
            $query = array(
                'author'      => $current_user->ID,
                // the post type/custom post type we are modifying
                'post_type'   => 'post',
    			
                'post_status' => $type['status']
            );
            $result = new WP_Query($query);
            if( $type['status'] == NULL ):
                $class = ($wp_query->query_vars['post_status'] == NULL) ? ' class="current"' : '';
                $views['all'] = sprintf(__('<a href="%s"'. $class .'>All <span class="count">(%d)</span></a>', 'all'),
                    admin_url('edit.php?post_type=post'),
                    $result->found_posts);
            elseif( $type['status'] == 'publish' ):
                $class = ($wp_query->query_vars['post_status'] == 'publish') ? ' class="current"' : '';
                $views['publish'] = sprintf(__('<a href="%s"'. $class .'>Published <span class="count">(%d)</span></a>', 'publish'),
                    admin_url('edit.php?post_status=publish&post_type=post'),
                    $result->found_posts);
            elseif( $type['status'] == 'draft' ):
                $class = ($wp_query->query_vars['post_status'] == 'draft') ? ' class="current"' : '';
                $views['draft'] = sprintf(__('<a href="%s"'. $class .'>Draft'. ((sizeof($result->posts) > 1) ? "s" : "") .' <span class="count">(%d)</span></a>', 'draft'),
                    admin_url('edit.php?post_status=draft&post_type=post'),
                    $result->found_posts);
            elseif( $type['status'] == 'pending' ):
                $class = ($wp_query->query_vars['post_status'] == 'pending') ? ' class="current"' : '';
                $views['pending'] = sprintf(__('<a href="%s"'. $class .'>Pending <span class="count">(%d)</span></a>', 'pending'),
                    admin_url('edit.php?post_status=pending&post_type=post'),
                    $result->found_posts);
            elseif( $type['status'] == 'trash' ):
                $class = ($wp_query->query_vars['post_status'] == 'trash') ? ' class="current"' : '';
                $views['trash'] = sprintf(__('<a href="%s"'. $class .'>Trash <span class="count">(%d)</span></a>', 'trash'),
                    admin_url('edit.php?post_status=trash&post_type=post'),
                    $result->found_posts);
            endif;
        }
    	
        return $views;
    }
    
  • when I checked my code it was not working although I was sure it had been before!!!

    Anyhow with a combination of things this is definitely working on my site now, you need the filters to modify the numbers of posts shown at the top of the list of posts screen.

    function listings_for_current_author($query) {
    	
    	if( !$query->is_admin )
    		return $query;
    		
    	if( isset($query->query_vars['post_type']) &&  $query->query_vars['post_type'] == 'acf' )
    {
    	return $query;
    }
    		
    	
    	if( !current_user_can( 'moderate_comments' ) ) {
    		global $user_ID;
    		$query->set('author', $user_ID );
    		add_filter('views_edit-site_listings', 'fix_listing_counts');
                    add_filter('views_upload', 'fix_listing_media_counts');
    	}
    	return $query;
    }
    
    add_action('pre_get_posts', 'listings_for_current_author');
    
    // Fix post counts
    function fix_listing_counts($views) {
        global $current_user, $wp_query;
    	/*
    	unset($views['all']);
                unset($views['publish']);
                unset($views['trash']);
    	*/
    	
    	
        unset($views['mine']);
        $types = array(
            array( 'status' =>  NULL ),
            array( 'status' => 'publish' ),
            array( 'status' => 'draft' ),
            array( 'status' => 'pending' ),
            array( 'status' => 'trash' )
        );
        foreach( $types as $type ) {
            $query = array(
                'author'      => $current_user->ID,
                //'post_type'   => 'post',
    			'post_type'   => 'site_listings',
                'post_status' => $type['status']
            );
            $result = new WP_Query($query);
            if( $type['status'] == NULL ):
                $class = ($wp_query->query_vars['post_status'] == NULL) ? ' class="current"' : '';
                $views['all'] = sprintf(__('<a href="%s"'. $class .'>All <span class="count">(%d)</span></a>', 'all'),
                    admin_url('edit.php?post_type=site_listings'),
                    $result->found_posts);
            elseif( $type['status'] == 'publish' ):
                $class = ($wp_query->query_vars['post_status'] == 'publish') ? ' class="current"' : '';
                $views['publish'] = sprintf(__('<a href="%s"'. $class .'>Published <span class="count">(%d)</span></a>', 'publish'),
                    admin_url('edit.php?post_status=publish&post_type=site_listings'),
                    $result->found_posts);
            elseif( $type['status'] == 'draft' ):
                $class = ($wp_query->query_vars['post_status'] == 'draft') ? ' class="current"' : '';
                $views['draft'] = sprintf(__('<a href="%s"'. $class .'>Draft'. ((sizeof($result->posts) > 1) ? "s" : "") .' <span class="count">(%d)</span></a>', 'draft'),
                    admin_url('edit.php?post_status=draft&post_type=site_listings'),
                    $result->found_posts);
            elseif( $type['status'] == 'pending' ):
                $class = ($wp_query->query_vars['post_status'] == 'pending') ? ' class="current"' : '';
                $views['pending'] = sprintf(__('<a href="%s"'. $class .'>Pending <span class="count">(%d)</span></a>', 'pending'),
                    admin_url('edit.php?post_status=pending&post_type=site_listings'),
                    $result->found_posts);
            elseif( $type['status'] == 'trash' ):
                $class = ($wp_query->query_vars['post_status'] == 'trash') ? ' class="current"' : '';
                $views['trash'] = sprintf(__('<a href="%s"'. $class .'>Trash <span class="count">(%d)</span></a>', 'trash'),
                    admin_url('edit.php?post_status=trash&post_type=site_listings'),
                    $result->found_posts);
            endif;
        }
    	
        return $views;
    }
    
    // Fix media counts
    function fix_listing_media_counts($views) {
        global $wpdb, $current_user, $post_mime_types, $avail_post_mime_types;
        $views = array();
        $_num_posts = array();
        $count = $wpdb->get_results( "
            SELECT post_mime_type, COUNT( * ) AS num_posts 
            FROM $wpdb->posts 
            WHERE post_type = 'attachment' 
            AND post_author = $current_user->ID 
            AND post_status != 'trash' 
            GROUP BY post_mime_type
        ", ARRAY_A );
        foreach( $count as $row )
            $_num_posts[$row['post_mime_type']] = $row['num_posts'];
        $_total_posts = array_sum($_num_posts);
        $detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
        if ( !isset( $total_orphans ) )
            $total_orphans = $wpdb->get_var("
                SELECT COUNT( * ) 
                FROM $wpdb->posts 
                WHERE post_type = 'attachment' 
                AND post_author = $current_user->ID 
                AND post_status != 'trash' 
                AND post_parent < 1
            ");
        $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
        foreach ( $matches as $type => $reals )
            foreach ( $reals as $real )
                $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
        $class = ( empty($_GET['post_mime_type']) && !$detached && !isset($_GET['status']) ) ? ' class="current"' : '';
        $views['all'] = "<a href='upload.php'$class>" . sprintf( __('All <span class="count">(%s)</span>', 'uploaded files' ), number_format_i18n( $_total_posts )) . '</a>';
        foreach ( $post_mime_types as $mime_type => $label ) {
            $class = '';
            if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
                continue;
            if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
                $class = ' class="current"';
            if ( !empty( $num_posts[$mime_type] ) )
                $views[$mime_type] = "<a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), $num_posts[$mime_type] ) . '</a>';
        }
        $views['detached'] = '<a href="upload.php?detached=1"' . ( $detached ? ' class="current"' : '' ) . '>' . sprintf( __( 'Unattached <span class="count">(%s)</span>', 'detached files' ), $total_orphans ) . '</a>';
        return $views;
    }
    
  • Ok this problem is resolved. I took a new approach with a fresh mind.

    I searched the database for ALL meta_key’s with a value LIKE ‘resume’ (the name of the ACF field in question). I figured it was worth doing instead of using the ‘=’ operand.

    I found 2 references. One as ‘Resume’ and one as ‘resume’. The ‘resume’ key was from ACF and the ‘Resume’ key was an old key from a year ago before I switched over to ACF. It had a value of null. The ‘resume’ field had an ID value.

    Interestingly enough as soon as I deleted the ‘Resume’ record ACF started to work just fine.

    I know its an oddball situation but there was obviously some conflict with ACF getting the field from the DB with the same name but different case settings. Worth you looking into still.

  • Hey Elliot,

    Thanks for the reply. As far as all your questions are concerned. I have run quite a few tests already of which using the ID, Object and URL were part of that.

    In the admin side of things I can select the image through the ACF field from both the media library or upload a new one. If I upload a new one it get uploaded to the custom directory I assigned in my plugin file just fine. It even shows in the media library as well. And I can use the basic WP Media Insert button to insert the file into the post content. This works and displays on the admin and client sides.

    What is interesting is that when I select the file with ACF (using the ‘select’ button in the media library) the file seems to be assigned to the post / page. However if I leave the page and come back to it the ACF field is blank again.

    On the client / user side the file never seems to appear. It has a null value.

    As far as debuging: “Have you debugged the result of get_field()?” I have tried several of my own methods – including checking the DB fields with phpMyAdmin and in all cases it seems to be a null value for ACF. If you have a specific test you could suggest I would be more than happy to test it. I am quite adept at PHP and WordPress.

  • Hi @rainstorminc

    Because your case is quite specific, I would encourage you to add a filter to the pre_get_posts and edit the ‘wrong’ settings that the events post type plugin is adding.

    I would rather not bloat the core and add potential issues for other users if possible.

    Thanks for understanding and thanks for the bug report.

    Cheers
    E

  • Hi @Patrik

    That’s more of a question for google and the WP codex.

    Cheers
    E

  • @RichB, @karlkinkin, maybe you guys should read that great article posted by @elliot : http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/ and this one also of not done yet : http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/

    Here is a quick overview of what I understand from these articles, hope it helps :

    According to the atticle called “Using acf_form to create a new post”, by hooking to acf/pre_save_post, the function you assign (my_pre_save_post) receives an ID. This ID comes from the post_id passed to acf_form function. If you pass it “new” instead of a post ID, you can do whatever you want, such as creating a post, plus, your custom fields will be saved automatically if you return a post ID after your custom code is executed. You can also see that the function my_pre_save_post returns the post ID and does nothing else if the ID is different than “new”. This is because the function acf_form does the updating job automatically, so there is no need to hook to acf/pre_save_post here.

    Also, by adding the prefix “user_” to your ID, acf_form saves user metas instead of post metas. Ain’t that great !

    That said, @RichB, you might need to split your user management and post creation/updating in two separate pages. I don’t know exactly what your use case is but it looks you are calling acf_form with wrong parameters.

    Cheers !
    Dominic

  • Hi Elliot,

    Thanks for the response!

    Yes, I agree — it’s perfectly reasonable to suspect that post__in would be enough. The conflict occurs with another plugin that handles Event custom post types.

    This events plugin uses the “pre_get_posts” method. During the process of using this method, the plugin will end up adding a tiny piece to the query if it has to do with a post_type that the plugin is responsible for. Ie, your query says “Give me all post types” and then the event plugin says “hey, that query has to do with events — so add on this event-related piece”. The end result is that the query doesn’t return anything because the event piece isn’t appropriate to be added in this case since it’s not really about events.

    I’ll be the first to admit that there’s probably something that could change in the event plugin to avoid this issue. Having said that, my guess is that ACF is more widely supported than the other and therefore, more likely to be updated. Plus, I figured the update actually made sense anyway to restrict the results to certain post_types. Especially, since it was already filtering to certain post_types anyway, it just wasn’t being that specific.

    What do you think?

Viewing 25 results - 20,976 through 21,000 (of 21,363 total)