Support

Account

Forum Replies Created

  • Glad I could help. Though, would you please un-mark your post as “topic solution” and mark mine instead, please? I need it for my e-genitals.

  • Have you actually checked if the field is configured to return an array?
    Please dump the contents of the field via var_dump( $row ) and show me what it spits out.

  • Is this what you mean to do?

    echo  '<a href="' . get_term_link( $type ) . '">'
        . '<img class="imagenes" src="' . $image['url'] . '" />'
        . '</a>'
        . '<div class="name">' . $type->name . '</div>'
        . '<small>' . $type->name . '</small>';
  • Well, two things:

    Firstly, like when someone goes on the internet and asks: “What is the average amount of tar in a cigarette,” and a hundred people just ignore the question and immediately post: “STOP SMOKING” in all-caps, this is going to be a bummer, but: Are you absolutely certain, that you have to update this website, that was built in the era of Internet Explorer 10, and that it would not be much easier to migrate the data into a fresh install?

    Secondly, if you are certain, that it is necessary: Have you tried deactivating all plugins, updating WordPress, then updating the plugins one by one, and then re-activating them one by one? In any case, please make a copy of the database.

  • I do not see you using the second argument anywhere. Assuming that event_details is a field of $post, you should pass the post ID at least to have_rows(). In case this is not it, we should find out where exactly the problem occurs:

    • Have you checked if $post is being populated as intended?
    • Have you checked if the ID property of $post is “ID” and not “id” or “post_id”?
    • Have you factored in that when you call get_the_ID() you are asking for the ID of the current main loop item, for which you have called the template?
  • I suppose you are using a File field. In that case you can specify that the field returns an array (see the screenshots in the documentation). Then you should be able to call the title using $file['horse_official_document']['filename'].

  • Thanks for that explanation.
    On my end, this usort() call does exactly what it is supposed to:

    <?php
    $arr = [
    	0 => [ 'bird_name' => 'C' , ] ,
    	1 => [ 'bird_name' => 'X' , ] ,
    	2 => [ 'bird_name' => 'A' , ] ,
    	3 => [ 'bird_name' => 'F' , ] ,
    ];
    
    usort(
    	$arr ,
    	function( $a , $b ) { return strcmp( $a['bird_name'] , $b['bird_name'] ); }
    );
    
    var_dump( $arr );
    /*
    Prints:
    
    array(4) {
      [0]=>
      array(1) {
        ["bird_name"]=>
        string(1) "A"
      }
      [1]=>
      array(1) {
        ["bird_name"]=>
        string(1) "C"
      }
      [2]=>
      array(1) {
        ["bird_name"]=>
        string(1) "F"
      }
      [3]=>
      array(1) {
        ["bird_name"]=>
        string(1) "X"
      }
    }
    */

    Are the names perhaps prefixed with information that does not belong there, for example:

    • “B” is in fact “other_pigeons_and_doves B”
    • “A” is in fact “pigeons_and_doves A”
    • “X” is in fact “pigeons_and_doves X”

    and so on? No other possibility comes to my mind.

    Please post an example of data that is not sorted correctly.

  • I cannot comprehend how we managed to overlook this.

  • I have no idea what that sentence means.

  • I do not mind taking a look, but you should know that I will be out of office for a week or longer. Do not count on me if you happen to be in a hurry.

  • sort() sorts an array by value, but in this case the value is an array with two keys. So, which one should it pick for sorting, “bird_name” or “price”? The code cannot know. You have to tell it.
    For this purpose usort() allows you to define a function that is used for sorting:

    usort(
    	$final_array ,
    	function( $a , $b ) { return strcmp( $a['bird_name'] , $b['bird_name'] ); }
    );
  • You have it the other way around: You have to apply $post->ID to the functions in the template, not the foreach.
    The “within-the-loop”-functions, so to speak, such as get_permalink() use the current post to fetch information. That is how it is intended. But you can pass $post->ID as an argument to most of them (some have to be replaced), so they will fetch information on the current post of the foreach.
    Try this:

    <?php
    /**
     * Programmes Block Template.
     *
     * @param   array $block The block settings and attributes.
     * @param   string $content The block inner HTML (empty).
     * @param   bool $is_preview True during AJAX preview.
     * @param   (int|string) $post_id The post ID this block is saved to.
     */
    
    // Create id attribute allowing for custom "anchor" value.
    $id = 'prog-' . $block['id'];
    if ( ! empty( $block['anchor'] ) ) {
    	$id = $block['anchor'];
    }
    
    // Create class attribute allowing for custom "class_name" and "align" values.
    $class_name = 'progBlock';
    if ( ! empty( $block['class_name'] ) ) {
    	$class_name .= ' ' . $block['class_name'];
    }
    
    if ( ! empty( $block['align'] ) ) {
    	$class_name .= ' align' . $block['align'];
    }
    
    if ( $is_preview ) {
    	$class_name .= ' is-admin';
    }
    ?>
    
    <div id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class_name ); ?>">
    
    	<?php
    	$posts = get_field( 'progs' );
    	if ( $posts ) :
    	?>
    
    	<div class="progGrid grid-x grid-margin-x grid-margin-y">
    		<?php foreach ( $posts as $post ) : ?>
    			<div class="card cell small-12 medium-6 large-4">
    				<img role="img" src="<?php echo get_the_post_thumbnail_url( $post , 'foureighty' ); ?>" alt="<?php echo get_the_title( $post ); ?>"/>
    				<div class="progText">
    					<div class="progTitle">
    						<h3 class="blog-title">
    							<a href="<?php echo esc_html( get_permalink( $post ) ); ?>" alt="<?php the_title_attribute( [ 'post' => $post ] ); ?>">
    								<?php echo get_the_title( $post ); ?>
    							</a>
    						</h3>
    					</div>
    					<div class="progExcerpt">
    						<h3 class="blog-title show-for-large">
    							<a href="<?php echo esc_html( get_permalink( $post ) ); ?>" alt="<?php the_title_attribute( [ 'post' => $post ] ); ?>">
    								<?php echo get_the_title( $post ); ?>
    							</a>
    						</h3>
    							<?php echo get_the_excerpt( $post ); ?>
    					</div>
    				</div>
    			</div>
    		<?php endforeach; ?>
    	</div>
    
    	<?php endif; ?>
    </div>
    
  • I do not see you trying to fetch the image anywhere. If it is a subfield of the repeater, you should be able to use get_sub_field('the_image_field_name');.
    Here you are fetching the name twice:

    $value = get_sub_field('name');
    $label = get_sub_field('name');

    Is that intentional?

  • If you configure the Post Object field to return a post object instead of the post ids, it will deliver an array of post objects ready to use. No need to call global $post, setup_postdata( $post ), or wp_reset_postdata(). All of that seems to just unnecessarily confuse the page that is loading the block. In order to retrieve the permalink, the title, the featured image etc. of the posts assigned to the block, just use $post->ID within the foreach ( $posts as $post ).

  • I do not quite understand what you are trying to do. Are you talking about a clone field? Then yes; once you have set A to be a clone of B it pretty much does what it says on the package.

  • Is newsletter_link a property of the posts you loaded? Then, instead of the_sub_field( 'newsletter_link' ), try get_field( 'newsletter_link' , ( $post->ID ?? $post->post_id ?? $post ) ). Does that spit out what you want it to, or if not, what does it spit out?

  • Try explicitly declaring 'redirect' => true/false on all pages. Just a hunch, but, who knows?

  • The three options pages, that are displayed, are all endpoints of explicit redirects.

    • “Page Template Settings” is missing, but it redirects to “Pagestyle: Classic Layout,” which is printed.
    • “Documentation” redirects to a subpage, but there are none, so it is printed.
    • “Calendar API,” too, redirects to a subpage, but there are none, so it is printed.

    I do not know what to make of it though.

  • So far so good. Then it is definitely not a browser issue and not a CSS issue. Have you checked the code that registers the options pages? Perhaps strings are missing, or if they are wrapped in localization functions, such as __(), the translation is missing.

  • I am not sure I understand what you are trying to accomplish.

    So, you have a list of terms.
    For each term you create a query in order to fetch a list of posts.
    For each post you fetch multiple repeaters.
    For each repeater… Well, what is the content of these repeaters, and where do the filters come in?

    In any case, if you aim to filter posts after they have been fetched by the query, generally it is a good idea to iterate the query results with $query->the_post() and store the posts in another array for further processing, instead of printing them as they come.

  • The taxonomy field has a bunch of options that, I suppose, impact the ability to search terms, namely:

    1. Create Terms: Terms typed into the field will be newly created and added to the taxonomy (all the usual WP shenanigans attached, such as comma separation). You might not find terms, because they are being registered. Please check if previous searched have resulted in any data garbage being added to the taxonomy.
    2. Save Terms: Terms typed into the field will be added to the post itself be the usual means of WP. I venture that this will function only if the taxonomy itself is attached to the post type at hand. It might help to know what taxonomy we are dealing with.
    3. Load Terms: Terms typed into the field will be limited to the terms that have already been attached to the post. Basically, see 1 and 2.

    Which of these options, if any, are enabled?

  • Please check if the text is actually missing from the DOM, or if the text exists but is not displayed for whatever reason. That will give us some direction.
    Do you know how to go about this?

  • No worries, I am not on the run. Glad I could help.
    I would appreciate it though, if you could give me the thumbs up for “case solved”.

  • For some annoying reason my last reply was just gone, but I managed to restore it somehow. Maybe I pushed the wrong button, so please excuse any mail spam that might occur now.

    By your current setup this particular page (“Banner 1”) and all products each are given two fields: A link and a banner. Now you can assign them a link and a banner each. So, if you call get_field( 'my_custom_link_in_pages' ) on a product page, you are grabbing the link that you have assigned to this product. If you have not assigned this product a link, the function will return an empty value.

    Depending on what exactly your are trying to accomplish, there are three ways to solve this:

    1. You can assign your product the same link and banner that you have assigned “Banner 1”, so they now belong to the product as well.

    2. You can fetch the fields of “Banner 1” directly on every product page like this:

    <?php
    get_field( 'my_custom_link_in_pages' , $the_id_of_the_banner1_page )

    3. You can remove the second field group condition, so the fields no longer apply to product pages, then create a second field group, which contains a Post Object field, and then assign each product a page, the link and banner of which to use, like this:

    <?php
    $the_page_id = get_field( 'the_assigned_page' );
    is_object( $the_page_id ) ? $the_page_id = $the_page_id->ID : null ;
    $the_link = get_field( 'my_custom_link_in_pages' , $the_page_id  );
Viewing 25 posts - 1 through 25 (of 44 total)