Oh no, I’m not saying you should remove the attribute at all.
But maybe you misunderstood my problem. I am using the pagespeed server edition (I wasn’t talking about the one that is installed on top of Firebug or on Google Chrome). It’s a module that when installed on the server on top of apache or nginx, it will minify the final HTML, JavaScript and CSS code in order to optimize it.
One of pagespeed’s optimization features, is to remove the type='text'
from inputs, since according to the HTML5 w3 standard
The missing value [of the input’s type] default is the Text state.
http://www.w3.org/TR/html5/forms.html#attr-input-type
My request is just to add input:not([type])
to the jQuery selectors. So when the type is missing, it would be considered as if <input type='text' />
.
If you’re still not sure what I’m talking about, you can view the PageSpeed module here: https://developers.google.com/speed/pagespeed/module
Ah I see 🙂
We’ll then I’ll settle for the glory ey! ;P
This is the php file for the page;
<?php
/*
Template Name: Abous Us - Parent
*/
?>
<p>test</p>
<?php get_header(); ?>
<div id="content" class="group">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
$content = apply_filters( 'the_content', $content );
?>
<div id="aboutSub"><div class="entryHeader"><?php echo $page->post_title; ?></div>
<div class="entry"><?php echo $content; ?><img src="<?php the_field('image1'); ?>" alt="" /></div></div>
<?php
}
?>
<?php endwhile; endif; ?>
</div><!-- END content -->
<?php get_footer(); ?>
Child pages use default page templates.
Hi @soulhuntre
Your code looks good, make sure all the follow are correct:
1. $current_user->ID is valid data (print_r it to debug)
2. check postmeta table and find a value that your field has stored. What does the data look like. Is it a single ID? or is it an array?
3. print_r the result of $posts. What do you get?
Hi @Aurelien Denis
The easiest way to achieve this is to use the ‘post__in’ arg like so:
<?php
$post_ids = get_field('my_custom_field', false, false);
$posts = get_posts(array(
'post_type' => 'post',
'orderby' => 'post_date',
'post__in' => $post_ids,
));
if( $posts ) {
?>
<a title="<?php the_title_attribute(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
<?php } ?>
note the 2 false parameters in the get_field function? This will tell ACF not to format the value, so you will get an array of ID’s, not an array of post objects!
Thanks!
This old post solved my question:
http://old.support.advancedcustomfields.com/discussion/5905/add-gallery-field-data-through-php-with-update_field/p1
I only wish I could afford to buy a ticket from Vancouver BC Canada to WordCamp Europe. 😛
Sadly it’s not in this years budget.
I would suggest that you create a custom post type called “soccer fields”. Google custom Post type UI and you’ll find an easy to use plugin.
Then add a ACF field with a dropdown where the user can select either open or closed.
Then to output the soccer fields check out this: http://codex.wordpress.org/Class_Reference/WP_Query
and in the loop you can retrieve the open/close dropdown value using get_field or the_field and output along with any other info about the soccer field..
I’m afraid that’s the best I can do for you since this question is faaaar to general. However if you look into what I’ve given you and you are capable of doing a bit of coding you should be fine!
Haha that’s true.. kind of making a mountain out of a molehill.. 😉 But still, overcoming issues like these is what makes this job fun!
Yeah I suggest you try my last solution, according to my brains logic it should work in it’s simplicity!
Unfortunately I don’t have a paypal account since I rarely use paypal in my private life and usually just get the glory and appreciation of helping out!
But I don’t suppose you’ll be at the wordcamp europe this weekend?
You can fetch the image url with javascript and print it as an img tag..
I can’t say for sure how to get the image url since I cant see your setup in admin but try to figure out how to get it by:
var imgURL = $('your image object').attr('href');
//Then print it in your popup doing something like this (again, you'll have to change the target object to be correct
$('target object popup').append('<img src="' + imgURL + '" alt="" class="targetimage" />');
Jonathon,
Thanks so much for the help. I ended up just making the end date mandatory. This turned into to much work so I just went that route.
I’ll try your last suggestion still, but if I don’t use it I still wanted to just say thanks.
Send me your paypal email and I’ll buy you a beer.
Sure.
I’ve installed the timthumb code in its own directory within my theme.
I then have a field within my repeater called image
Finally, I have a line of PHP ($theme_path) which I call from my function file. This is simple the path to timthumbs files like so:
$theme_path =’http://www.domain.co.uk/wp-content/themes/theme_folder/’;
<img src="<?php echo $theme_path; ?>timthumb/timthumb.php?src=<?php the_sub_field('image'); ?>&w=618&h=298&q=100">
That should get you what you need. Hope that helps
Daft question!
How can I get the uploaded image into the JS script?
Am massively struggling so any help is very much appreciated
Thanks
Odd that your previous function didn’t work..
I tried thinking outside of what you’ve done so far and perhaps this would work? It’d be a lot simpler altho maybe not as good performance-wise.. I don’t think it matters tho since it’s in the admin and it’s not that big off a loss that anyone would notice.
function my_acf_save_post( $post_id )
{
//The fields have already been saved to the database so lets retrieve them
$event_start = get_field('field_5217ac66687dc', $post_id);
$event_end = get_field('field_524b4ca5ff418', $post_id);
//check if event_end exists, if it was empty it should not. You can make sure of this in database.. perhaps it has to be changed to $event_end == ''
if(!$event_end){
//update event_end. Parameters are field key of event_end, event_start value and the post id.
update_field('field_524b4ca5ff418', $event_start, $post_id);
}
}
// run AFTER ACF saves the $_POST['fields'] data to database
add_action('acf/save_post', 'my_acf_save_post', 20);
Got it to work using this code here:
function my_acf_load_field( $value, $post_id, $field )
{
$event_start = get_field_object('field_5217ac66687dc', $post_id);
$event_end = get_field_object('field_524b4ca5ff418', $post_id);
if( empty( $event_end['value'] )):
$value = $event_start['value'];
endif;
return $value;
}
//add_filter('acf/update_value/key=field_524b4ca5ff418', 'my_acf_load_field', 10, 3);
Problem is, if you save it duplicates it if empt, then if you clear it and hit save again, it is blank till you hit save a second time.
If anyone can solve this for me I’d love to buy them a few beers.
I’m not sure if it makes any difference or not that its a date picker field.
Sadly that didn’t work.
I checked the original method inside the acf.php file and tried this as well with no results.
function my_acf_save_post( $post_id )
{
// load from post
if( !isset($_POST['fields']) )
{
return false;
}
// loop through and save
if( $_POST['fields'] )
{
$fields = $_POST['fields'];
// concert details
// event start date
//$fields['field_5217ac66687dc']
// event end date
//$fields['field_524b4ca5ff418']
if( empty( $_POST['fields']['field_524b4ca5ff418'] ) )
$_POST['fields']['field_524b4ca5ff418'] = $fields['field_5217ac66687dc'];
// calendar details
// event start date
//$fields['field_524b4c06af2a2']
// event end date
//$fields['field_524b4c3aaf2a4']
if( empty( $_POST['fields']['field_524b4c3aaf2a4'] ) )
$_POST['fields']['field_524b4c3aaf2a4'] = $fields['field_524b4c06af2a2'];
foreach( $_POST['fields'] as $key => $value )
{
// parse types
// - caused issues with saving numbers (0 were removed)
//$value = apply_filters('acf/parse_types', $value);
// get field
$field = apply_filters('acf/load_field', false, $key );
// update field
do_action('acf/update_value', $value, $post_id, $field );
}
// foreach($fields as $key => $value)
}
// if($fields)
return true;
}
I’m super stumped, which sucks sine I write code all day long.
Hi @wightfield
I’ve just been looking into a solution for this issue.
I installed WPSEO, and yes, could see the visual issue of the ACF fields being added to the WPSEO section.
I have updated the JS to append the fields above the WPSEO section, so it looks like it is part of WP again!
As for the title, I don’t think I’ll add this into the taxonomy section as the title looks quite out of place.
I have however, added this functionality to the user edit screen.
Hope that helps.
Thanks
E
hey @sKuijers, this is exactly the question I’ve been trying to answer for a few hours! Have you made any progress?
Based on what I know at this point, my approach is to
1. Register my field groups.
2. Before rendering my settings page call
do_action('acf/input/admin_head');
do_action('acf/input/admin_enqueue_scripts');
3. Add a tag in my settings page template that renders the field.
The main conceptual block I’ve run into is how I should pass the “location” params in the register_field_group() call so it reference my settings page. The plugin slug I’m using is “es_awp” (i.e. the settings URL is `http://path.to.wordpress/wp-admin/options-general.php?page=es_awp’ so I figured I could do something like this (not sure it works):
'location' => array (
array (
array (
'param' => 'page',
'operator' => '==',
'value' => 'es_awp',
'order_no' => 0,
'group_no' => 0,
),
),
),
I’d love to hear your approach and see any code examples if you have. I’ll be sure to post my code if I figure it out too.
Thanks in advance for any help!
ah well..
If we look at the code logically.. you input the $_POST into the $fields variable.. then change the value of one of the array keys in $fields, but $_POST is never really altered.. $fields != $_POST if you see what I mean 🙂
So your code works in a sense but it is not affecting the actual values being saved.
I think this should work:
function my_acf_save_post( $post_id )
{
// vars
$fields = false;
// load from post
if( isset($_POST['fields']) )
{
$fields = $_POST['fields'];
// concert details
// event start date
//$fields['field_5217ac66687dc']
// event end date
//$fields['field_524b4ca5ff418']
if( empty( $fields['field_524b4ca5ff418'] ) )
$_POST['fields']['field_524b4ca5ff418'] = $fields['field_5217ac66687dc'];
// calendar details
// event start date
//$fields['field_524b4c06af2a2']
// event end date
//$fields['field_524b4c3aaf2a4']
if( empty( $fields['field_524b4c3aaf2a4'] ) )
$_POST['fields']['field_524b4c3aaf2a4'] = $fields['field_524b4c06af2a2'];
}
// ...
}
// run before ACF saves the $_POST['fields'] data
add_action('acf/save_post', 'my_acf_save_post', 1);
I suppose you could clean that up a bit if you like and I’m not 100% sure if I wrote the $_POST[‘field’][‘fieldkey’] correctly since I havent looked at the arrays myself but all in all it should set you on the right path!
Same problem here. Today I see that a few fields of a large field group disapeared in the back end. I don’t know after what update this comes, but now I can re-add and after saving there gone again. 🙁
But sometimes – I don’t know when – some fields appeared again and after next saving they are gone again …
Then use a die at the end of the loop.
Can you specify what I must do?
@elliot, Thank you for the clear & quick reaction.
I have had a quick look in the input.php file and think I’ll be able to find my way from there. When I have done some coding I’ll let you know how it worked out.
Did that already. It prints out an array of fields. That’s actually how I got the field keys.
Maybe I’m wrong about what the hook does and how it does it. Is the $fields array saved, or is the $_POST array saved.
All I know is when I hit update, the end date field is still blank.
are you sure the fields are even set?
You could do some debugging:
print_r($fields);
die();
put that after you set the $fields variable. when you update a post it should then just send you to a white page within the admin with the $fields variable printed.
Hi Jonathan, I still cannot get this working for some reason. the_permalink($postid); still displays the current page url instead of the parent.
Sorry I’m no php expert, I’d appreciate if you could tell me what’s wrong. Here is the entire code of the actual template.
<?php
/*
Template Name: Page CEO Massage
*/
?>
<?php get_header(); ?>
<section id="slider">
<div id="page-title-container">
<h1 id="page-title"><?php
echo empty( $post->post_parent ) ? get_the_title( $post->ID ) : get_the_title( $post->post_parent );
?></h1>
</div>
</section>
<section id="content">
<div id="col-lt">
<?php
global $post;
if($post->post_parent){
$postid = $post->post_parent;
}else{
$postid = $post->ID;
}
?>
<?php if(get_field('content-container', $postid)): ?>
<ul>
<?php while(has_sub_field('content-container', $postid)): ?>
<li><a href="<?php the_permalink($postid); ?>#<?php echo preg_replace('/[^A-Za-z0-9]/', "", get_sub_field('header')); ?>"><?php the_sub_field('header'); ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div>
<div id="col-rt" class="top_no_padding">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<p><?php the_field('ceo_message'); ?></p>
<?php endwhile; endif; ?>
</div>
</section>
<?php get_footer(); ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.