Forum Replies Created

  • Try this and let me know what you get:

    $args = array( 
        'post_type' => 'cars', 
        'posts_per_page' => 999,
        'meta_key' => 'price',
        'meta_type' => 'NUMERIC',
        'orderby' => 'meta_value_num',
        'order' => 'ASC'                        
  • You could do this with jQuery. Why not just use a repeater?

  • Thanks John, I use this but I think post locking can only be done on the back end.

  • I found this on the web. Don’t know a lot about custom shortcodes, but I tested this and it worked.

    $shortcode = get_post_meta($post->ID,'YOUR_CUSTOM_FIELD_NAME',true);
    echo do_shortcode($shortcode); 
  • I would add a post object field to your flexible content field that returns the page ID. It provides a page link. When you loop through the flexible content field you can add logic: if the post object field = the page you want the content to appear, echo the WYSIWYG field. I can guide you through this if you are unfamiliar.

  • Is your checkbox field set to return values?

  • Your post object is alrwady set to return an ID, but you have $post_object->ID. Remove the ->ID and it should work.

  • Just set up your radio button with yes and no as choices.

    When you go to display the field, your code will be something like this:

    if( get_field('yes_no') == 'Yes':
        echo "<label style='color:green'>Yes</label>";
    elseif( get_field('yes_no') == 'No'):
        echo "<label style='color:red'>No</label>";
  • Found this: nl2br function

  • I think you are trying to pass an array in the update field function and you haven’t defined a field. I think you need to pass a number to the post object. You may want to add another variable to get the page ID.

    Whatever $nombre_cargo is, you need to use the field name or field key as the first parameter of the update field function. For example: ‘nombre_cargo’ or ‘field_123456890’

    Try this, but replace the name of the field first.

    $per_obj = get_page_by_title( $resp, OBJECT, 'persona' );
    if (!is_null($per_obj)) {
            $page = per_obj->ID;
    update_field( 'cargo_number', $page, $post_id );
  • If I understand you correctly, it looks like you are trying to get the choices in the post object to display in alphabetical order.

    Have you tried the following:

    function my_post_object_query( $args, $field, $post_id ) {
        // modify args
        $args['orderby'] = 'title'; //title of the post
        $args['order'] = 'ASC'; //order a-z; use DESC for z-a
        // return
        return $args;
    add_filter('acf/fields/post_object/query/key={field key}', 'my_post_object_query', 10, 3);

    Change the field key to the field key for your post object (it should look like this: acf/fields/post_object/query/key=field_508a263b40457 . Then add the code to your functions.php file

    Documentation Hier

  • What type of field is your project_total_prints field? I’m assuming it is a WYSIWYG field. And are you trying to get the number of media (pictures) that have been uploaded to this field?

  • I’m not sure if you just want the content or if you want the ability to have that field when you edit the page.

    If you are tying to get the content, you would just add echo get_field(‘what_we_do’,[post_ID of the page]);

    If you want it to appear when you edit a page, just create a new location rule for that page:

  • Please show your code and list all the fields in the repeater. I can’t tell how many date fields you have. You should be able to loop through the sub fields. I’m willing to help.

  • Instead of adding 16 individual boxes, I would put the boxes that are going to hold the scores inside the player post in a repeater. You can set the minimum and maximum rows to the number of games in the tournament.

    This is a sample:

  • Here is a picture of a repeater that I use for my site:

  • This is somewhat involved, but assuming you have a player post for every player and a post for tracking the scores for each game, I would do the following:

    Create a taxonomy for the games. Ex.: Summer Tournament 2018.
    Create a field group with a number field for each game. So, if there are 16 games, there will be 16 boxes. Set your rules to have these appear where the Post Type is Player (or whatever your CPT is for players).

    Create a repeater with two fields: a post object field (players) and a number field. This should appear in whatever post or page you are using to keep track of a given game. The post object field will link the game to the player. Set your rules to appear where Post Type is (whatever post you are tracking the scores for each game) and the Taxonomy is (whatever you call your tournament). This is where you will track the scores for each player for a given game.

    Create a post for each of the summer games.

    The update field function will involve:
    Running a query to get the post ids for all the summer games.
    An outside loop of all the summer games, and an inside loop of the repeater with the scores for each game.
    Now you can grab the post id of the player and update the box corresponding to the game in the players profile.

    Now you can loop through each player and show their points on a separate page.

  • Are you trying to total the points for each game that a player scored points and then post the player’s total points on a single page?

  • One option would be to create a front-end form and just include that one field in the form:

    The documentation is here: Front end form

  • This question is hard to read without using the ‘code’ tags. Can you add these to any text in this post that you want to be read as code?

  • Yes, here’s an example:

    The code below adds the roster for a team based on certain criteria.

    function add_away_rosters_select($field){
    		$sports_cat = array('boys-basketball','girls-basketball','boys-hockey','girls-hockey','baseball','softball','boys-lacrosse','girls-lacrosse','boys-tennis','girls-tennis');
    		$cat = get_the_category();
    		$sport = $cat[0]->slug;
    		$field['choices'] = array();
    		if( in_array($sport,$sports_cat) ){
    		$away = get_field('away_team_2')->ID;
    		$args_1['post_type'] = 'roster';
    		$args_1['post_status'] = 'publish';
    		$args_1['order_by'] = 'title';
    		$args_1['order'] = 'ASC';
    		$args_1['meta_key'] = 'school_team';
    		$args_1['meta_value'] = $away;
    		$args_1['category_name'] = $sport;
    		$args_1['posts_per_page'] = -1;
    		$away_players = get_posts($args_1);
    		$away_roster = array();
    		for($i = 0; $i < count($away_players); $i++){
    			$away_player = get_field('last_name',$away_players[$i]->ID).", ".get_field('first_name',$away_players[$i]->ID);	
    			$away_player_ID = $away_players[$i]->ID;
    			$away_roster[$away_player_ID] = $away_player;	
                $field['choices'] = $away_roster;
    		return $field;
    // changes the choices to players from the away rosters
    add_filter('acf/load_field/key=field_58dadbb26c60a', 'add_away_rosters_select');
  • You have to add this to your query:

    So if you were trying to look for houses with the following criteria:
    CPT: houses
    Country: United States
    City: Los Angeles
    Beach: Manhattan

    I don’t know what your taxonomy slugs are, but insert them own below:

    $args = array(
    	'post_type' => 'houses',
    	'tax_query' => array(
    		'relation' => 'AND',
    			'taxonomy' => 'country',
    			'field'    => 'name',
    			'terms'    => 'United States',
    			'taxonomy' => 'city',
    			'field'    => 'name',
    			'terms'    => 'Los Angeles',
    			'taxonomy' => 'beach',
    			'field'    => 'name',
    			'terms'    => 'Manhattan',
  • Can you show your code?

  • Are you trying to get the number of days between the two dates?
    if so:

    $date_1 = date_create(get_field('retreat_date_from'));
    $date_2 = date_create(get_field('retreat_date_to'));
    $diff = date_diff($date_1,$date_2);

    This will show you the output:

    echo "<pre>";
    echo $diff->days;
    echo "</pre>";
  • Thanks, I’ll try the plugin.

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

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.