Support

Account

Forum Replies Created

  • Sorry about that. I’m drunk. It’s get_field, not get_the_field.

    <?php
    $cat = get_field('artist_news');
    $recentposts=get_posts('showposts=3&category=$cat');
    
    if ($recentposts) {
    ... rest of your code
    ?>
  • Hi John,

    1) Create a radio field. Give it a few values. For this example, set the field name to ‘my_radio’
    2) Save the fieldset (shouldn’t be needed but just in case)
    3) Create an image field
    4) At the bottom, set Conditional Logic to “Yes”
    5) In the dropdowns, select “my_radio” then “is equal to” and the last box should show a list of the options you entered into the radio field.

    Getting the field info up to the body element is going to be tricky because of how/where you position the loop. Instead of using inline styles you could create a javascript block that adds that $style line to the body element. Something like jQuery('body').css('background-color', <?php echo $color; ?>); where the css line would change depending on the conditional check in my first reply.

    No idea how to do the dynamic style sheet thing. ๐Ÿ™‚

  • You should be able to throw this in before the return, building the variables first.
    <?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?>

    http://codex.wordpress.org/Function_Reference/wp_mail has the details.

  • You may be running up against WordPress’ maximum custom fields count. Add this to your functions.php file and give it another shot. Might not be the issue at all but it would help to rule it out.

    add_filter( 'postmeta_form_limit' , 'customfield_limit_increase' );
    function customfield_limit_increase( $limit ) {
    	$limit = 100;
    	return $limit;
    }
  • 1) Absolutely. Set up the radio button field with two values: image and color (you can label them whatever you like). Set up the color picker field, set up the image field. Set the color and image fields to only display when the related radio button is selected via “Conditional Logic” at the bottom of their respective fieldsets.

    2) I’d probably do this with inline css to save the headache. Set any sort of global stuff in your stylesheet and then in the template something along the lines of this should get you going:

    
    <?php
    	$backgroundType = get_field('the-type-radio-button-field-name');
    
    	if ($backgroundType == "image"){
    		$style = "background-image: " . the_field('your-image-field-name');
    	} else { //it's a color
    		$style = "background-color: " . the_field('your-color-picker-field');
    	}
    ?>
    	<div style="<?php echo $style; ?>">
    		Content Here.
    	</div>
    
    
  • Try this:

    <?php
    $cat = get_the_field('artist_news');
    $recentposts=get_posts('showposts=3&category=$cat');
    ?>

    Not exactly sure how WordPress functions handle variables inside of strings like that so you might need to do this:

    <?php
    $cat = get_the_field('artist_news');
    $recentposts=get_posts('showposts=3&category=' . $cat);
    ?>
  • oops, forgot the closing ?> on that first line.

  • Don’t know if that’s possible but you can do it with some Javascript shenanigans.

    jQuery('#id-of-you-fieldbox').insertBefore('#submitdiv');

  • @jeffreyd00 Here, with less noise:

    <?php
        $theEmail = get_sub_field('staff_email_address');
        <a href="mailto:<?php echo antispambot( $theEmail ) ?>">
           <?php the_sub_field('staff_name'); ?>
        </a>
    ?>
  • Lovely! Thank you. ๐Ÿ™‚

  • You have it right. See if these help you nail it down:
    http://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls/ (the middle bit)
    http://wordpress.org/support/topic/search-form-with-custom-taxonomy-dropdown

    You may want to do something like getting all of the specialties of only the doctors at that particular location instead of displaying unavailable specialties and bumming people out! this should get you close. http://wordpress.stackexchange.com/a/125374

  • Sounds like you have the image field set to return the image object. If you just want the url, set the field’s return value in the Fields editor to “Image Url”.

    See the docs for examples of using all three return value types http://www.advancedcustomfields.com/resources/field-types/image/

  • Thanks a lot for the reply @elliot. As you can probably tell from the length of the post, my eyes started bleeding thinking through it. Going to start building it again in earnest tomorrow.

    Shortcodes for inner content differences is (suddenly!) obvious and brilliant. Thank you!

  • I’ve run into issues before with having too many post revisions stored in the database. Cleaning them out helped. You can run this query to see where you’re at.

    SELECT COUNT(*) FROM wp_posts WHERE post_type = "revision"

    if you have wp cli installed it’s as easy as

    /path/to/wordpress/ $ wp db query 'SELECT COUNT(*) FROM wp_posts WHERE post_type = "revision"'

    If that number seems high (I can’t really say what high is, depends on how many posts you have) you could make a backup of your db (!), delete all the revisions and see if that speeds things up.

    /path/to/wordpress/ $ wb db export /path/to/your/backup/home/mysite.snapshot.sql

    /path/to/wordpress/ $ wp db query 'DELETE FROM wp_posts WHERE post_type = "revision"'

    There are plugins to make deleting a little more nuanced. Say, delete all but the last 2 revisions or whatever.

    If that turns out to be the problem, you can permanently cap the revisions count in your wp-config with this line:

    define( 'WP_POST_REVISIONS', 3 );

    More info here: http://codex.wordpress.org/Editing_wp-config.php#Specify_the_Number_of_Post_Revisions

  • tl;dr Forum isn’t having any part of displaying the encoded text as anything but output. Save the email address as a variable first and then pass it to antispambot to make all of you obfuscation dreams come true. If you view source on this forum post and search for “foo” you can see it in action.

    Interesting. I’m not sure why but I see a way around it. Perhaps @elliot can explain the discrepancy.

    Note: the_field("test_email") was saved as "[email protected]"
    THIS CODE:
    <h2> The Email: <?php echo antispambot( "[email protected]" ) ?> </h2>
    <h2> The Email: <?php echo antispambot( the_field("test_email") ) ?> </h2>
    OUTPUTS:
    <h2> The Email: test@test.com </h2>
    <h2> The Email: [email protected] </h2>

    THIS CODE: (Save as variable first)
    <h2> The Email: <?php echo antispambot( "[email protected]" ) ?> </h2>
    <?php $email = get_field("test_email"); ?>
    <h2> The Email: <?php echo antispambot( $email ) ?> </h2>

    OUTPUTS: What you (we!) were expecting:
    <h2> The Email: test@test.com </h2>
    EDIT: Can’t get it to display properly in the forum but this email address is obfuscated.
    <h2> The Email: foo@bar.com </h2>

    edited for clarity.

  • Actually, now that I’m on it… ๐Ÿ™‚

    p code { margin: 0}

    will keep inline codeblocks from vertically breaking
    up paragraphs with an extra 40px of margin and

    
    pre code { 
      color: #DD1144; 
    }
    

    will keep the code inside of pre blocks the same color (red) as code inside of paragraph blocks.

  • For contributions to the docs you could open a โ€œissues-onlyโ€ repo on GitHub.

    Or a separate docs repo. That would also allow you to have branches/tags to match the current code base. Folks could add docs for new features before they’re live and there’s no need to worry about which docs are live. When the code updates, the docs do too.

    I’d help out here and there as I come across things but the barrier to entry is a little blurred.

  • I might be misunderstanding but the image object should provide you with both the URL and the ID.

    Be sure to set the upload to “Image Object” in the ACF field editor. Then something like this should work:

    $img = get_field('image');
    <a href=<?php echo $img["url"] ?> rel="lightbox">
      <span class="ititle"><?php the_field('titre'); ?></span>
      <img src=<?php echo $img["sizes"]["large"]; ?> />
    </a>

    Replace [“large”] with which ever size you want. Do a print_r($img) to see what’s available.

  • oops, sorry about that. “Untested” ๐Ÿ™‚ Try this, also untested!

    <div class="staff-email">Email:
        <a href="mailto:<?php echo antispambot(the_sub_field('staff_email_address')); ?>">
    <?php echo antispambot(the_sub_field('staff_email_address')); ?>
    </a>
    </div>
    

    If that’s working, make sure that the_sub_field('staff_email_address') is actually outputting an email address.

  • Wordpress limits to 30 by default. See the source here:
    https://core.trac.wordpress.org/browser/tags/3.8/src/wp-admin/includes/template.php#L556

    add_filter( 'postmeta_form_limit' , 'customfield_limit_increase' );
    function customfield_limit_increase( $limit ) {
        $limit = 60;
        return $limit;
    }

    in your functions.php should set you up.

  • What is your front end code?

  • Do you mean you want to display the first image in the gallery by itself? If so, with the code you have $images[0] will be the first image. So something like this should work:

    <img src="<?php echo $images[0]["sizes"]["large"]; ?>" >

    You don’t need to put that in the foreach loop. Just after checking if($images):

  • Untested but this should work:

    <div class="staff-email">Email:
        <?php
          echo antispambot(the_sub_field('staff_email_address'));
        ?>
    </div>
    
  • Hmm. I justed tested the same (new field group, no fields with content area turned off) and it worked as expected. I only tried it with a specific post (as well as a specific page) and I don’t have 2014 installed so perhaps not a 1:1 comparison.

    Do you have any other field groups assigned to those pages. If so, they may be over riding the settings for your newest group.

    If multiple field groups appear on an edit screen, the first field group's options will be used. (the one with the lowest order number)
    
  • Thanks again for that clue @reardestani. I’ve spent some time today trying to copy from/reconcile code from radio.php into checkbox.php. It’s almost working but not quite. I think I have the code in the create_field() method working ok but it all seems to fall apart within the update_value() method.

    function update_value( $value, $post_id, $field )
    {
    	var_dump($value);
    	... <snip> ...
    }
    

    Produces (with the ‘other’ and another box checked)

    array(2) {
      [0]=>
      string(8) "firstVAL"
      [1]=>
      string(5) "other"
    }
    

    Then, I loop through it

    foreach($value as $key => $v)
    {
    	if ( !in_array($v, $field['choices']) )
    	{
    		echo "key: " . $key . "      /     v: " . $v . "\n\n";
    		array_push($field['choices'], $v);
    	}
    }
    

    and that of course produces:

    key: 0      /     v: firstVAL
    key: 1      /     v: other
    

    Not the value of the textinput but the value of the checkbox.

    Can someone set me straight here? How can I find the value of that text input I’ve created within the create_field() function?

    This is with the Save ‘other’ values to the field’s choices set to on FWIW. In the end, I won’t actually want that (awesome) functionality – there will be many different editors of this ‘form’ and they don’t all need to see the values saved by others. I tried turning it off but when I reloaded my my edit (custom) post, the value wasn’t saved. For now anyway, I’m going down this path.

    Once I sort it out, I’ll clean up my mayhem and submit it as a pull request in case it’s useful to anyone else.

    Cheers,
    Will

Viewing 25 posts - 26 through 50 (of 51 total)