Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi Elliot,

    Actually, I realised that I don’t need to work with “ID” at all. Instead, I can use “Object” type and still have a custom size as a thumbnail.

    So what I do now is have a function like this:

    	/**
    	* Add automatic image sizes
    	*/
           if ( function_exists( 'add_image_size' ) ) { 
    	add_image_size( 'smallsquare', 45, 45, false ); //false: soft prop crop, true: hard crop
    	}

    which creates ‘smallsquare’.

    So I can use ‘smallsquare’ with Object and get done what I wanted like this:

    <a href="<?php the_field('race_website') ?>" target=_new>
    						<img class="race_wiki_img" alt="" src="<?php $image = get_field('race_logo'); echo($image['sizes']['smallsquare']); ?>" />
    						</a>

    A very friendly suggestion, perhaps make this clearer in the docs for future users? The way it is written I got the idea that only predefined sizes can be used with Object, but if you want custom sizes you need to use ID.

    Thanks for the help

  • Hi Elliott,

    I was excited to try the code found on the page you referred to. After trying it out, it still did not work. This is the code I used with my field name substituted in…it’s been inserted under the word “Profile”:

    <?php
     
    $author_id = get_the_author_meta( 'ID' );
    $author_badge = get_field('donor_image1', 'user_'. $author_id ); // image field, return type = "Image Object"
     
    ?>
    <img src="<?php echo $author_badge['url']; ?>" alt="<?php echo $author_badge['alt']; ?>" width="200" height="100" />

    Keep in mind that this isn’t for an actual post page but is for an author page (author.php). The url is http://choochooclan.com/surrogate/author/egglady/ or http://choochooclan.com/surrogate/?author=11 Given that the author ID is 11, I would think that the code would pull that in dynamically and then look for the appropriate image field which is donor_image1 and then display it accordingly. As you can see this is not happening. Is there something else I need to add to the code?

  • Hi @jason@epagecity.com

    You can use this action to enqueue scripts/styles for a page which displays custom fields – http://www.advancedcustomfields.com/resources/actions/acfinputadmin_enqueue_scripts/

  • So I can thus far save my flexible content field layout to post_content with:

    //save field content to the_content
    function save_to_the_content( $value, $post_id )
    {
    		wp_update_post( array( 'ID' => $post_id, 'post_content' =>  $value ) );
    		return $value;
    }
    add_filter('acf/update_value/key=field_5318e88463d1e', 'save_to_the_content', 10, 3);

    I’m still struggling with getting it to work the opposite way – post_content to flexible content layout. I’m able to sort of accomplish it with this:

    //multi-dimensional array in_array
    function multi_in_array($value, $array) 
    { 
        foreach ($array as $item) 
        { 
            if (!is_array($item)) 
            { 
                if ($item == $value) 
                { 
                    return true; 
                } 
                continue; 
            } 
    
            if (in_array($value, $item)) 
            { 
                return true; 
            } 
            else if (multi_in_array($value, $item)) 
            { 
                return true; 
            } 
        } 
        return false; 
    } 
    
    function save_to_acf_layout( $value, $post_id, $field )
    {
    
    $field_key = "field_5318e86463d1d";
    $value = get_field($field_key);
    
    $page = get_post();
    $string = $page->post_content;
    
    if(!multi_in_array("the_content", $value) && $string != '') :
    	$value[] = array("text" => $string, "acf_fc_layout" => "the_content");
    	update_field( $field_key, $value, $post_id );
    endif;
    }
    
    add_action('save_post', 'save_to_acf_layout');
    

    I’m struggling to get both functions working together. And my second function is imperfect – doesn’t work exactly how I’d like. Thoughts?

  • Hi @galengidman

    A quick google showed some github repos that can be used to ‘recover’ the exported PHP:
    https://github.com/seamusleahy/ACF-PHP-Recovery

    Thanks
    E

  • Hi @uakz

    The tutorial in question shows a lot of complicated code, which I do no offer my services to login and debug.

    Please debug your code line by line to ensure all variables and values are as expected.

    Many plugins / theme code can modify and cause issues with the posts returned by a WP_Query, so perhaps it is possible that another source is causing no posts to be found.

    Most likely, it is a logic error in the code you have written that is causing the WP_Query to find no posts.

    Thanks
    E

  • Hi @miky

    Try not to feel ripped off, the theme developers are just doing their job. They have developed a theme which allows you to create a website just as advertised.

    If you want to also use ACF to extend the functionality, that’s fine, however this plugin is not a ‘one click install’ and requires much reading, coding and Code knowledge.

    Perhaps you should contract a web developer to help you out on this one.

    Thanks
    E

  • This reply has been marked as private.
  • Hi, Elliot.

    I have WP Custom Fields Search plugin installed – it is an exellent solution to search content from the front-end not only in Post Title or Post content, but all other custom fields.

    Unfortunately in back-end AJAX search for Relationship field is searching only Post Title, not even Post Content, as SnitchHomer said.

    Is it possible to do some customization to make search possible not only by Title, but by Body and all (or some) text custom fields?

    For example we have such structure:

    1. Movie post type
    2. Actor post type

    In Movie custom fields I have Actors realtionship field, that helps me to choose actors, that cast in the movie.

    Each Actor have additional Custom Fields, like Original name, Nickname and other Text Fileds, that helps me to quckly search actors database.

    It will be great if I can search Actors not only by their Name, but also any of Custom Fields.

    I would be grateful for any help.

  • I think you are right! Randomly last night it started being really quick… with no change to anything. Had to been something cached.

    Thanks

  • Hi Elliot,
    I hope you don’t mind double posting but I don’t want mix questions with my findings
    The acf.conditional_logic.change function has a line:
    $.each(this.items, function( k, item ){
    which loops through all items with conditional logic. In my case with 9 rows this.items has 255 elements and loop takes 10 seconds to complete.
    Each extra row add another 10-40 items depending on the complexity of the nested repeater fields.
    In the embedded code for each field you put them all in one bag:
    acf.conditional_logic.items.push({
    This ultimately kills the performance of conditional logic fields. I suggest you rewrite the code so the repeater field holds separate conditional_logic object with its own children only rather than refer to the global object with all items.
    I’ll keep digging what is causing other slowdowns.

  • Hi @Elliot

    Thanks for your reply worked great.
    Here is the code I used for anyone that may need it. This will get the qtranslate tags working in the field labels and field instructions of a front-end form.

    function my_acf_load_field( $field )
    {
        if(!is_admin()){
            $field['label']  =  apply_filters('the_title', $field['label']);
            $field['instructions']   =  apply_filters('the_title', $field['instructions']);
        }
        return $field;
    }
    add_filter('acf/load_field', 'my_acf_load_field');

    I used is_admin()==false to make sure this only applies to the front-end forms. When used across the whole plug-in, the apply_filters functions seems to be called when acf prints the name of the field label in the wp-admin pages. Making the qtranslate tags invisible the first time you save the form and removing them completely if you save again.

    With is_admin() the translations will be visible in the admin pages while editing forms but this is not an issue in my case.

    Thanks again 🙂

  • Hi @Jursdotme

    Thanks for the request. I’ll see what I can do about this one, but it would be very complicated!

    Thanks
    E

  • Hi @diegoquintana

    The first place to look is the wp_postmeta table. Please make sure that after you ‘broadcast’ your data, that the old and new table data match up correctly.

    If all the postmeta data exists, the issue is most likely a mismatch in the reference value.

    Each time you save a value (repeater field), ACF also saves a ‘reference’ from the value back to the field that saved it. This can be seen as an underscored version of the value.

    On your 2nd site, it is possible that your repeater field has a different key as your first site. This mismatch would prevent the repeater field from loading all the data correctly for the has_sub_field while loop.

    Check your 2 sites and edit the field groups, tick the screen option to show the field keys and check that they are the same. If not, you will need to copy / replace the field in the DB to make sure the keys are the same

    Thanks
    E

  • Hi @benluoma

    Why not write a custom function that you run only once? Think of it as a ‘migration’ function.

    In this function you could query all posts, and loop over them. For each post, you can load in the flexible content field value, and append the post_content if not already added (somewhat similar to your above code).

    This would mean that you only need to run the function once, then comment it out and all your posts should be updated!

    Thanks
    E

  • for the form its

    the code bellow

    <?php
    /**
     * Template Name:create memorial Template
     *
     * @package WooFramework
     * @subpackage Template
     */
    
    acf_form_head();
     
    get_header(); ?>
    
        <!-- #content Starts -->
    <?php woo_content_before(); ?>
        <div id="content" class="col-full">
        
        <div id="main-sidebar-container">    
    
                <!-- #main Starts -->
                <?php woo_main_before(); ?>        
    
     
    	<div id="primary">
    		<div id="content" role="main">
     
    			<?php the_post(); ?>
     
    			<?php acf_form( $options ); ?>
     
    		</div><!-- #content -->
    	</div><!-- #primary -->
     
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
                       
    <?php
    woo_loop_before();
    if (have_posts()) { $count = 0;
    while (have_posts()) { the_post(); $count++;
    woo_get_template_part( 'content', 'page' ); // Get the page content template file, contextually.
    }
    }
    woo_loop_after();
    ?>     
                </section><!-- /#main -->
                <?php woo_main_after(); ?>
        
                <?php get_sidebar(); ?>
    
    </div><!-- /#main-sidebar-container -->         
    
    <?php get_sidebar( 'alt' ); ?>
    
        </div><!-- /#content -->
    <?php woo_content_after(); ?>
    
    <?php get_footer(); ?>

    the single memorial code

    <?php
    /**
     * Template Name:create memorial Template
     *
     * @package WooFramework
     * @subpackage Template
     */
    the_post();
    
    $template = get_field('template', $post->ID);
    if (empty($template)) {
        $template = 'standard';
    }
    $template_dir = get_stylesheet_directory() . '/memorials';
    $template_uri = get_stylesheet_directory_uri() . '/memorials';
    $templateFile = $template_dir . '/' . strtolower($template) . '.php';
    if (file_exists($templateFile)) {
        include($templateFile);
    }
    

    and the custom post type plugin

    ?php
    
    /*
      Plugin Name: Lvd4Evr - Memorial Custom Post Type
      Plugin URI:
      Description:
      Version: 1.0.0
      Author: Kathryn Reeve
      Author URI: http://BinaryKitten.com
      License: GPLv2
     */
    
           
    
    class j20_lovedforever_memorial
    {
    
        public function __construct()
        {
            add_action('init', array($this, 'create_post_type'), 0);
            $this->addAcf();
        }
    
        function create_post_type()
        {
    
            $labels = array(
                'name' => _x('Memorials', 'Post Type General Name', 'text_domain'),
                'singular_name' => _x('Memorial', 'Post Type Singular Name', 'text_domain'),
                'menu_name' => __('Memorial', 'text_domain'),
                'parent_item_colon' => __('Parent Memorial:', 'text_domain'),
                'all_items' => __('All Memorials', 'text_domain'),
                'view_item' => __('View Memorial', 'text_domain'),
                'add_new_item' => __('Add New Memorial', 'text_domain'),
                'add_new' => __('Add New Memorial', 'text_domain'),
                'edit_item' => __('Edit Memorial', 'text_domain'),
                'update_item' => __('Update Memorial', 'text_domain'),
                'search_items' => __('Search Memorials', 'text_domain'),
                'not_found' => __('No Memorial Found', 'text_domain'),
                'not_found_in_trash' => __('Memorial not found in Trash', 'text_domain'),
            );
            $rewrite = array(
                'slug' => 'memorial',
                'with_front' => true,
                'pages' => false,
                'feeds' => false,
            );
            $args = array(
                'label' => __('memorial', 'text_domain'),
                'description' => __('Memorial Pages', 'text_domain'),
                'labels' => $labels,
                'supports' => array('title', 'author','comments'),
                'taxonomies' => array('category', 'memorial'),
                'hierarchical' => false,
                'public' => true,
                'show_ui' => true,
                'show_in_menu' => true,
                'show_in_nav_menus' => true,
                'show_in_admin_bar' => true,
                'menu_position' => 20,
                'menu_icon' => '',
                'can_export' => true,
                'has_archive' => true,
                'exclude_from_search' => false,
                'publicly_queryable' => true,
                'rewrite' => $rewrite,
                'capability_type' => 'page',
            );
    
            register_post_type('memorial', $args);
    
            register_post_type( 'tribute',
                array(
                    'labels' => array(
                        'name' => __( 'Tributes' ),
                        'singular_name' => __( 'tribute' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'tribute'),
                )
            );
    
            register_post_type( 'stories',
                array(
                    'labels' => array(
                        'name' => __( 'stories' ),
                        'singular_name' => __( 'stories' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'stories'),
                )
            );
    
            register_post_type( '_user_video',
                array(
                    'labels' => array(
                        'name' => __( 'Video' ),
                        'singular_name' => __( 'video' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'video'),
                )
            );
        }
    
        public function addAcf() {
         //   include plugin_dir_path(__FILE__) . DIRECTORY_SEPARATOR . 'acf.php';
        }
    
    }
    
    new j20_lovedforever_memorial();
    
    function my_pre_save_post( $post_id )
    {
        
        
        
        // Create a new post
        $post = array(
            'post_status'  => 'publish' ,
            'post_title'  =>  $_POST['title'],
            'post_type'  => 'memorial' ,
        );  
      
      
        if(get_post($id)) {
            $post_id = wp_update_post( get_post($post_id) );  
        } else {
            $post_id = wp_insert_post( $post );  
        };
        // insert the post
       
       
    
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
     
        // return the new ID
        return $post_id;
    }
    
     
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    
    add_action('init', 'process_choose_template');
    
    function process_choose_template(){
     if(isset($_POST['choose-template'])) {
        $template = $_POST['template'];
        $post_id = $_POST['post_id'];
        add_post_meta(  $post_id , 'memorial_template', $template, true ) || update_post_meta(  $post_id , 'memorial_template', $template );
        wp_redirect( get_permalink($post_id) ); 
        exit(); 
     }
    }
    
    function memorial_save_post_class_meta($post_id, $post ) {
        if (get_post_type( $post ) == 'memorial'){
            $template = $_POST['template'];
            add_post_meta(  $post_id , 'memorial_template', $template, true ) || update_post_meta(  $post_id , 'memorial_template', $template );
    
        }
    }
    
    /* Fire our meta box setup function on the post editor screen. */
    
    //Meta Box 
    /* Meta box setup function. */
    function memorial_post_meta_boxes_setup() {
    
        /* Add meta boxes on the 'add_meta_boxes' hook. */
        add_action( 'add_meta_boxes', 'memorial_add_post_meta_boxes' );
    
        /* Save post meta on the 'save_post' hook. */
        add_action( 'save_post', 'memorial_save_post_class_meta', 10, 2 );
    }
    
    /* Create one or more meta boxes to be displayed on the post editor screen. */
    function memorial_add_post_meta_boxes() {
    
        add_meta_box(
            'memorial-post-class',          // Unique ID
            'Templates',      // Title
            'memorial_post_class_meta_box',     // Callback function
            'memorial',                 // Admin page (or post type)
            'side',                 // Context
            'default'                   // Priority
        );
    }
    
    function memorial_post_class_meta_box( $object, $box ) { ?>
        <?php $value = get_post_meta( $object->ID, 'memorial_template', true )?>
    
        <div>
            <label for=''>Template 1</label>
            <div class='chose-template-input'><input type='radio' name='template' value='1'  <?php echo ($value  == '1'|| $value  == '' ? 'checked="checked"' : '');?>></div>
        </div>
         <div>
            <label for=''>Template 2</label>
            <div class='chose-template-input'><input type='radio' name='template' value='2' <?php echo ($value  == '2' ? 'checked="checked"' : '');?>></div>
        </div>
         <div>
           <label for=''>Template 3</label>
            <div class='chose-template-input'><input type='radio' name='template' value='3' <?php echo ($value  == '3' ? 'checked="checked"' : '');?>></div>
        </div>
                     
                            
     <?php }            
    
    add_action( 'load-post.php', 'memorial_post_meta_boxes_setup' );
    add_action( 'load-post-new.php', 'memorial_post_meta_boxes_setup' );
    
        // Disable Admin Bar for everyone but administrators
    if (!function_exists('df_disable_admin_bar')) {
    
        function df_disable_admin_bar() {
            
            if (!current_user_can('manage_options')) {
            
                // for the admin page
                remove_action('admin_footer', 'wp_admin_bar_render', 1000);
                // for the front-end
                remove_action('wp_footer', 'wp_admin_bar_render', 1000);
                
                // css override for the admin page
                function remove_admin_bar_style_backend() { 
                    echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
                }     
                add_filter('admin_head','remove_admin_bar_style_backend');
                
                // css override for the frontend
                function remove_admin_bar_style_frontend() {
                    echo '<style type="text/css" media="screen">
                    html { margin-top: 0px !important; }
                    * html body { margin-top: 0px !important; }
                    </style>';
                }
                add_filter('wp_head','remove_admin_bar_style_frontend', 99);
                
            }
        }
    }
    
    //add_action('init','df_disable_admin_bar');
    
    add_action('pre_get_posts','ml_restrict_media_library');
    
    function ml_restrict_media_library( $wp_query_obj ) {
        global $current_user, $pagenow;
        if( !is_a( $current_user, 'WP_User') )
        return;
        if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
        return;
        if( !current_user_can('manage_media_library') )
        $wp_query_obj->set('author', $current_user->ID );
        return;
    }
    
    function tribute() {
      
        if(isset($_POST['submit_tribute'])){
              global $current_user;
              get_currentuserinfo();
            $post = $_POST['post_id'];
           $new_post = array(
                    'post_title' => $current_user->display_name,
                    'post_content' => $_POST['copy'],
                    'post_status' => 'publish',
                    'post_date' => date('Y-m-d H:i:s'),
                    'post_author' => $current_user->ID,
                    'post_type' => 'tribute',
                    'post_category' => array(0)
                    );
    
                   
            $post_id = wp_insert_post($new_post);
                add_post_meta(  $post_id , 'memorial_id', $post, true ) || update_post_meta(  $post_id , 'memorial_id', $post );
              wp_redirect( get_permalink($post) ); 
            exit(); 
        }
     
    }
    add_action('init','tribute');
    
    function stories() {
      
        if(isset($_POST['submit_Stories'])){
              global $current_user;
              get_currentuserinfo();
            $post = $_POST['post_id'];
           $new_post = array(
                    'post_title' => $current_user->display_name,
                    'post_content' => $_POST['copy'],
                    'post_status' => 'publish',
                    'post_date' => date('Y-m-d H:i:s'),
                    'post_author' => $current_user->ID,
                    'post_type' => 'stories',
                    'post_category' => array(0)
                    );
    
                   
            $post_id = wp_insert_post($new_post);
                add_post_meta(  $post_id , 'memorial_id', $post, true ) || update_post_meta(  $post_id , 'memorial_id', $post );
              wp_redirect( get_permalink($post) ); 
            exit(); 
        }
     
    }
    add_action('init','stories');
    
    function video() {
    
        if(isset($_POST['submit_video'])){
            global $current_user;
              get_currentuserinfo();
            $post = $_POST['post_id'];
           $new_post = array(
                    'post_title' => $current_user->display_name." ".$_POST['embed'],
                    'post_content' => $_POST['embed'],
                    'post_status' => 'publish',
                    'post_date' => date('Y-m-d H:i:s'),
                    'post_author' => $current_user->ID,
                    'post_type' => '_user_video',
                    'post_category' => array(0)
                    );
    
            $info = video_image($_POST['embed']);      
            $post_id = wp_insert_post($new_post);;
            update_field( 'video', $_POST['embed'], $post_id  );  
            update_field('image_url', $info, $post_id  );  
            add_post_meta(  $post_id , 'memorial_id', $post, true ) || update_post_meta(  $post_id , 'memorial_id', $post );  
            wp_redirect( get_permalink($post) ); 
            
        }
     
    }
    
    add_action('init','video');
    
    function video_image($url){
        $image_url = parse_url('http://'.$url);
        if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com'){
            $array = explode("&", $image_url['query']);
            return "http://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg";
        } else if($image_url['host'] == 'www.vimeo.com' || $image_url['host'] == 'vimeo.com'){
            $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".substr($image_url['path'], 1).".php"));
            return $hash[0]["thumbnail_small"];
        }
    }

    I hope this helps if you need any more info i can provide this

  • Hi @dalbeck

    You can achieve this by writing some custom jQuery / PHP. If you are not familiar with writing custom jQuery / AJAX / PHP scripts, you may need to contract a developer to do this for you.

    Upon ‘change’ of the post object field, you will need to perform a custom AJAX query to get the selected post’s content.

    With the post’s content returned, you will then need to use JS to update the WYSIWYG field. This is not the easiest task, but is possible by reading over the js/input.js file and scrolling down to the WYSIWYG section. You will see many tinymce functions which you can use to update the value.

    Thanks
    E

  • Hi @caram

    You could better optimize the code by making use of the get_field function instead of the get_post_meta function. This will allow ACF to cache data and only load it once (instead of twice in your case):

    
    <?php  if( get_field('yyy') ) { ?>
        <span class="info-detail"><?php  the_field('yyyy'); ?></span>
    <?php  } ?>
    

    This said, your code should not be maxing out memory limits, so it’s more likely to be a ‘too many plugins / functionality’ issue. Perhaps a server upgrade is needed or you can remove some plugins / functionality.

    Thanks
    E

  • Hi @elliot,

    I think the default WP_Query behaviour is to search both post_title and post_content, so I am surprised this is not working in the Relationship field.

    Assuming this was a choice made by you, is there any suitable hook in ACF to override this? (Such as a filter in Relationship field.)

    Or do you think there is a WP core hook?

  • Thanks Elliot. How do you queue up a jquery script to only run on pages that have the flexible content fields?

  • Thanks for getting back to me @elliot.

    We had some genuine text that was output in the usual way, this had been replaced on several pages by spurious text, arabic etc etc. Just general stuff you tend to get in spam comments.

    We have several other fields on the page with the front end forms that weren’t touched, it only seemed to be the text and textarea inputs.

    Out of 140 custom posts, there was at least a quarter of them hacked with very similar text.

    We have the WP Security plugin so everything apart from this is very secure. We’re very certain they’re getting in via the front end form text/textarea fields somehow.

  • Hi @jason@epagecity.com

    You can easily add this via some custom jQuery on the page.

    Just add an .on('click') event to the elements (via their class) and the use the confirm JS function to make a prompt.

    I’ll think about adding this to the core, but for now, a custom script will be the fastest way to see this implemented.

    Thanks
    E

  • Hi @SnitchHomer

    The relationship field uses a WP_Query to find the posts. In the args, the search parameter is set as s. You can read about this here: http://codex.wordpress.org/Class_Reference/WP_Query

    It is possible then to find a plugin or write some custom code that extends the WP search functionality to search also the post_content.

    Thanks
    E

  • Hi @donad

    Thanks for the bug report. This compatibility issue has been raised, but no fix has been found.

    Would you please also contact the WPML support and raise this with them?

    One other question. Have you had this same issue when using the image field? Or does the image field work correctly with WPML translations?

    Thanks
    E

  • Hello guys!
    I’m here just to reiterate the request for this functionality 🙂

Viewing 25 results - 18,601 through 18,625 (of 21,364 total)