Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • This reply has been marked as private.
  • Hi There, I am starting to understand this, but I am not quite there yet. I have a test post at:

    https://www.barakaentodos.com/wp/test/

    Where I checked:
    screened_porch
    bed_linens_provided
    fireplace

    and it displays out:

    // do something 1 // do something 1 // do something 1

    If the do something could be replaced with the field label or:

    Screened Porch
    Bed Linens Provided
    Fireplace

    that would be ideal, but I am not quite sure how to do that?

  • Well..

    I think you need to use other function. https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/

    Something like this:

    
    <img src="<?php echo get_the_post_thumbnail_url( $location->ID, 'thumbnail' ) ?>" />
    
  • This reply has been marked as private.
  • This should work with something like:

    
    $args = array(
            'post_type' => 'your_custom_post_type',
            'meta_key'=> 'your_field_date',
            'orderby' => 'meta_value',
            'order' => 'ASC' 
        );
    

    If you’re are working with the archive page, maybe a best way to do it is modify the main query with the pre_get_posts hook.

    For Example:

    
    // in your functions.php
    function sort_by_date_my_cpt( $query ) {
       if ( is_post_type_archive( 'your_custom_post_type') ) {
          $query->set('meta_key', 'your_date_custom_field');
          $query->set('orderby', 'meta_value');
          $query->set('order', 'ASC');
          return;
       }
    }
    add_filter( 'pre_get_posts', 'sort_by_date_my_cpt', 1);
    

    So then, you will to use your WP Loop by default in your archive template.

    
    // in your archive-your_custom_posttype.php or archive.php
    <?php if ( have_posts() ) :
       <?php while ( have_posts() ) : the_post(); ?>
       <?php endwhile; ?>
    <?php endif; ?>
    
  • This is absolutely a great technique. All the live TV shows, series, live TV channels for free on your Android devices using Cloud TV app.

    videoder apk
    redbox tv

  • I tried hiding the title using the first block of code and ended up hiding the entire WP editor.

    This:

        <style type="text/css">
          #post-body-content {
            display: none;
          }
        </style>

    Should be replaced by:

        <style type="text/css">
          #titlediv {
            display: none;
          }
        </style>

    if the aim is hiding only the “title” field of the editor.

    Glad I found this.

  • thanks 🙂 it’s working

    the final code:

    
     while ( have_rows('reseaux-sociaux', 'option') ) : the_row(); 
    		   	 echo '<ul>';
    					foreach ($fields as $sub_field) {	
    						$field = get_sub_field_object($sub_field);
    						$lien = $field['value'];
    						$image =  $field['label'];
    						if ($field['value']){
    						echo '<li><a href="'.$lien.'" target="_blank"><img src="'.get_stylesheet_directory_uri().' /imgs/icons/social/rondes/pleines/' . $image. '-icon.svg"></a></li>';
    						}			
    					}
    				echo '</ul>';
           endwhile;
  • Page is equal to home

    Unless there is a home page template that does not use these same fields I would not do anything more complicated.

    They choose the template. The template uses the fields with the different HTML for the layout if needed. I would probably go with template parts where the content output is the same.

    If you need to specify to use the fields only on home and on some templates

    Page is equal to Home (AND)
    Template is equal to Home page template 1
    (OR)
    Page is equal to Home (AND)
    Template is equal to Home page template 2

  • numberposts does not work in WP_Query, use posts_per_page

  • You should post these type of question in the issues over on the github repo, this is really not an ACF issue.

    However, the ACF JS API was completely rewritten for ACF 5.7.0 and you will need to rewrite the JS used by the code you copied. I have done this for another of those examples and you can see the types of changes that need to be made there https://github.com/Hube2/acf-dynamic-ajax-select-example/blob/master/dynamic-select-example/dynamic-select-on-select.js

  • Another cause of this issue is that there is a pre_get_posts filter that is interfering with the queries that ACF does to get the image information. You’d have to search your code to find this.

  • Yes – acf-quick-edit-fields is awesome and works great.

    You do need to read the setup instructions

    1) You must download from the releases page unless you want to build it yourself using npm and gulp. Don’t just try to use the default github zip.

    2) You must go into your ACF field settings and check the boxes for each field you want to be editable by quickedit or bulk edit. (or add new settings 'allow_quickedit' => 1, 'allow_bulkedit' => 1, in the PHP if you manage your fields settings in PHP)

    I’ve also used Admin Columns Pro and that’s pretty great too…

  • Well @alicam, I guess you’re not alone — but maybe both of us are.

    I face this situation frequently, and it seems our uses of clone field are pretty close, when I need two (or more) fields groups that are visually and semantically the same (let’s say a basic Text/Textarea/link group) but the names need to be different depending on context (like Title/Content/Link for the first and Name/Bio/Contact for the second).

    I start trying to find words that can serve for both titles, but that’s not practical and I end up creating two field groups that are *exactly the same*.

    That’s not very smart, but sadly it seems that is what it is.

    Hope some of staff members reach out this thread 🙂

  • Add this to functions.php file:

    add_action( 'run_video_embed', 'video_embed' );
    
    function video_embed( $context ) {
    
        $video = get_field( 'media' );
    	
    	if ( $video ) {
    		// Add autoplay functionality to the video code
    		if ( preg_match('/src="(.+?)"/', $video, $matches) ) {
    			// Video source URL
    			$src = $matches[1];
    			
    			// Add option to hide controls, enable HD, and do autoplay -- depending on provider
    			$params = array(
    				'controls'    => 1,
                    'hd'        => 1,
                    'fs'        => 1,
                    'rel'        => 0,
                    'modestbranding' => 1,
    				'autoplay' => 0
    			);
    			
    			$new_src = add_query_arg($params, $src);
    			
    			$video = str_replace($src, $new_src, $video);
    			
    			// add extra attributes to iframe html
    			$attributes = 'frameborder="0"';
    			
    			$video = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $video);
    		}
    	
    		echo '<div class="video-embed">', $video, '</div>';
    	}
    }

    and add this in Twig

    {% do action('run_video_embed') %}

  • My variant page-nav plugin:

    Create folder xakplag and file xakplag.php

    <?php
    
    /**
     * @package Xakplag
     */
    /*
    Plugin Name: Xakplag
    Plugin URI:
    Description: Xakplag
    Version: 0.1.0
    Author:
    Author URI: https://xakplant.ru/
    License: GPLv2 or later
    Text Domain: xakplag
    */
    use JasonGrimes\Paginator;
    
    define( 'XAKPAG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    
    require_once XAKPAG_PLUGIN_DIR . 'Paginator.php';
    
    $xakpag_count;
    
    function add_repeater_query_var(){
        global $wp;
        $wp->add_query_var('program-course-abroad-settings');
    }
    /* Rewrite rules albums pagination */
    function add_repeter_rewrite_rule() {
    
    // page=program-course-abroad-settings - change
        add_rewrite_rule('^/page/([0-9]+)/?$', '/wp-admin/admin.php?page=program-course-abroad-settings&page=$matches[1]', 'top');
    }
    add_filter('init', 'add_repeater_query_var');
    add_action('init', 'add_repeter_rewrite_rule');
    add_action('init', 'xakpag_query_page');
    function xakpag_query_page(){
    // change
        if($_GET['page'] == 'program-course-abroad-settings' && !$_GET['xp']){
    
            function prepare($field){
    
                $field['value'] = array_slice($field['value'], 0, 30);
    
                return $field;
            }
    // Your field name
            add_filter('acf/prepare_field/name=get_program_course_abroad_settings', 'prepare');
    
        } elseif ($_GET['page'] == 'program-course-abroad-settings' && $_GET['xp']){
    
            function prepare($field){
    
                global $xakpag_count;
    
                $xakpag_count = count($field['value']);
    
                $offset = intval($_GET['xp']);
    
                $offset = ($offset - 1) * 30;
    
                $field['value'] = array_slice($field['value'], $offset, 30);
    
                return $field;
            }
    
    // Chande field name
    
            add_filter('acf/prepare_field/name=get_program_course_abroad_settings', 'prepare');
    
        }
    }
    
    add_action('acf/render_fields', 'xakpag_print_nav', 30);
    function xakpag_print_nav($post){
    
        global $xakpag_count;
    
        $totalItems = $xakpag_count;
    
        $itemsPerPage = 30;
        $currentPage = getCurrentPage();
    
    // Your url pattern
        $urlPattern = 'https://expertno1.com/wp-admin/admin.php?page=program-course-abroad-settings&xp=(:num)';
    
        $paginator = new Paginator($totalItems, $itemsPerPage, $currentPage, $urlPattern);
    
        $screen = get_current_screen();
        if($screen->id == 'nastrojki-programm_page_program-course-abroad-settings'){
            ?>
    
                <div class="xakpag-pagination" style="display: flex">
    
    <?php echo $paginator->toHtml(); ?>
    
                    <style>
                        .active a {
                            font-weight: 900;
                        }
                    </style>
                </div>
    
            <?php
        }
    
    }
    function getCurrentPage(){
        if($_GET['xp']){
            return intval($_GET['xp']);
        } else {
            return 1;
        }
    }
    
    function gerCoutRepeater($repeter){
        if( have_rows($repeter) ):
            $i = 0;
            while( have_rows($repeter) ): the_row();
                if( get_sub_field($repeter) ) $i++;
            endwhile;
            $tCount = $i;
        endif;
    
        return $tCount;
    }
    
    

    create file Paginator.php

    
    <?php
    
    namespace JasonGrimes;
    
    class Paginator
    {
        const NUM_PLACEHOLDER = '(:num)';
    
        protected $totalItems;
        protected $numPages;
        protected $itemsPerPage;
        protected $currentPage;
        protected $urlPattern;
        protected $maxPagesToShow = 10;
        protected $previousText = 'Previous';
        protected $nextText = 'Next';
    
        /**
         * @param int $totalItems The total number of items.
         * @param int $itemsPerPage The number of items per page.
         * @param int $currentPage The current page number.
         * @param string $urlPattern A URL for each page, with (:num) as a placeholder for the page number. Ex. '/foo/page/(:num)'
         */
        public function __construct($totalItems, $itemsPerPage, $currentPage, $urlPattern = '')
        {
            $this->totalItems = $totalItems;
            $this->itemsPerPage = $itemsPerPage;
            $this->currentPage = $currentPage;
            $this->urlPattern = $urlPattern;
    
            $this->updateNumPages();
        }
    
        protected function updateNumPages()
        {
            $this->numPages = ($this->itemsPerPage == 0 ? 0 : (int) ceil($this->totalItems/$this->itemsPerPage));
        }
    
        /**
         * @param int $maxPagesToShow
         * @throws \InvalidArgumentException if $maxPagesToShow is less than 3.
         */
        public function setMaxPagesToShow($maxPagesToShow)
        {
            if ($maxPagesToShow < 3) {
                throw new \InvalidArgumentException('maxPagesToShow cannot be less than 3.');
            }
            $this->maxPagesToShow = $maxPagesToShow;
        }
    
        /**
         * @return int
         */
        public function getMaxPagesToShow()
        {
            return $this->maxPagesToShow;
        }
    
        /**
         * @param int $currentPage
         */
        public function setCurrentPage($currentPage)
        {
            $this->currentPage = $currentPage;
        }
    
        /**
         * @return int
         */
        public function getCurrentPage()
        {
            return $this->currentPage;
        }
    
        /**
         * @param int $itemsPerPage
         */
        public function setItemsPerPage($itemsPerPage)
        {
            $this->itemsPerPage = $itemsPerPage;
            $this->updateNumPages();
        }
    
        /**
         * @return int
         */
        public function getItemsPerPage()
        {
            return $this->itemsPerPage;
        }
    
        /**
         * @param int $totalItems
         */
        public function setTotalItems($totalItems)
        {
            $this->totalItems = $totalItems;
            $this->updateNumPages();
        }
    
        /**
         * @return int
         */
        public function getTotalItems()
        {
            return $this->totalItems;
        }
    
        /**
         * @return int
         */
        public function getNumPages()
        {
            return $this->numPages;
        }
    
        /**
         * @param string $urlPattern
         */
        public function setUrlPattern($urlPattern)
        {
            $this->urlPattern = $urlPattern;
        }
    
        /**
         * @return string
         */
        public function getUrlPattern()
        {
            return $this->urlPattern;
        }
    
        /**
         * @param int $pageNum
         * @return string
         */
        public function getPageUrl($pageNum)
        {
            return str_replace(self::NUM_PLACEHOLDER, $pageNum, $this->urlPattern);
        }
    
        public function getNextPage()
        {
            if ($this->currentPage < $this->numPages) {
                return $this->currentPage + 1;
            }
    
            return null;
        }
    
        public function getPrevPage()
        {
            if ($this->currentPage > 1) {
                return $this->currentPage - 1;
            }
    
            return null;
        }
    
        public function getNextUrl()
        {
            if (!$this->getNextPage()) {
                return null;
            }
    
            return $this->getPageUrl($this->getNextPage());
        }
    
        /**
         * @return string|null
         */
        public function getPrevUrl()
        {
            if (!$this->getPrevPage()) {
                return null;
            }
    
            return $this->getPageUrl($this->getPrevPage());
        }
    
        /**
         * Get an array of paginated page data.
         *
         * Example:
         * array(
         *     array ('num' => 1,     'url' => '/example/page/1',  'isCurrent' => false),
         *     array ('num' => '...', 'url' => NULL,               'isCurrent' => false),
         *     array ('num' => 3,     'url' => '/example/page/3',  'isCurrent' => false),
         *     array ('num' => 4,     'url' => '/example/page/4',  'isCurrent' => true ),
         *     array ('num' => 5,     'url' => '/example/page/5',  'isCurrent' => false),
         *     array ('num' => '...', 'url' => NULL,               'isCurrent' => false),
         *     array ('num' => 10,    'url' => '/example/page/10', 'isCurrent' => false),
         * )
         *
         * @return array
         */
        public function getPages()
        {
            $pages = array();
    
            if ($this->numPages <= 1) {
                return array();
            }
    
            if ($this->numPages <= $this->maxPagesToShow) {
                for ($i = 1; $i <= $this->numPages; $i++) {
                    $pages[] = $this->createPage($i, $i == $this->currentPage);
                }
            } else {
    
                // Determine the sliding range, centered around the current page.
                $numAdjacents = (int) floor(($this->maxPagesToShow - 3) / 2);
    
                if ($this->currentPage + $numAdjacents > $this->numPages) {
                    $slidingStart = $this->numPages - $this->maxPagesToShow + 2;
                } else {
                    $slidingStart = $this->currentPage - $numAdjacents;
                }
                if ($slidingStart < 2) $slidingStart = 2;
    
                $slidingEnd = $slidingStart + $this->maxPagesToShow - 3;
                if ($slidingEnd >= $this->numPages) $slidingEnd = $this->numPages - 1;
    
                // Build the list of pages.
                $pages[] = $this->createPage(1, $this->currentPage == 1);
                if ($slidingStart > 2) {
                    $pages[] = $this->createPageEllipsis();
                }
                for ($i = $slidingStart; $i <= $slidingEnd; $i++) {
                    $pages[] = $this->createPage($i, $i == $this->currentPage);
                }
                if ($slidingEnd < $this->numPages - 1) {
                    $pages[] = $this->createPageEllipsis();
                }
                $pages[] = $this->createPage($this->numPages, $this->currentPage == $this->numPages);
            }
    
            return $pages;
        }
    
        /**
         * Create a page data structure.
         *
         * @param int $pageNum
         * @param bool $isCurrent
         * @return Array
         */
        protected function createPage($pageNum, $isCurrent = false)
        {
            return array(
                'num' => $pageNum,
                'url' => $this->getPageUrl($pageNum),
                'isCurrent' => $isCurrent,
            );
        }
    
        /**
         * @return array
         */
        protected function createPageEllipsis()
        {
            return array(
                'num' => '...',
                'url' => null,
                'isCurrent' => false,
            );
        }
    
        /**
         * Render an HTML pagination control.
         *
         * @return string
         */
        public function toHtml()
        {
            if ($this->numPages <= 1) {
                return '';
            }
    
            $html = '<ul class="pagination" style="display: flex">';
            if ($this->getPrevUrl()) {
                $html .= '<li><a style="    text-decoration: #444;
        display: block;
        padding: 8px 12px;
        color: #fff;
        background: #0085ba;
    " href="' . htmlspecialchars($this->getPrevUrl()) . '">&laquo; '. $this->previousText .'</a></li>';
            }
    
            foreach ($this->getPages() as $page) {
                if ($page['url']) {
                    $html .= '<li' . ($page['isCurrent'] ? ' class="active"' : '') . '><a style="    text-decoration: #444;
        display: block;
        padding: 8px 12px;
        color: #fff;
        background: #0085ba;
    " href="' . htmlspecialchars($page['url']) . '">' . htmlspecialchars($page['num']) . '</a></li>';
                } else {
                    $html .= '<li class="disabled"><span style="    text-decoration: #444;
        display: block;
        padding: 8px 12px;
        color: #fff;
        background: #0085ba;
    ">' . htmlspecialchars($page['num']) . '</span></li>';
                }
            }
    
            if ($this->getNextUrl()) {
                $html .= '<li><a style="    text-decoration: #444;
        display: block;
        padding: 8px 12px;
        color: #fff;
        background: #0085ba;
    " href="' . htmlspecialchars($this->getNextUrl()) . '">'. $this->nextText .' &raquo;</a></li>';
            }
            $html .= '</ul>';
    
            return $html;
        }
    
        public function __toString()
        {
            return $this->toHtml();
        }
    
        public function getCurrentPageFirstItem()
        {
            $first = ($this->currentPage - 1) * $this->itemsPerPage + 1;
    
            if ($first > $this->totalItems) {
                return null;
            }
    
            return $first;
        }
    
        public function getCurrentPageLastItem()
        {
            $first = $this->getCurrentPageFirstItem();
            if ($first === null) {
                return null;
            }
    
            $last = $first + $this->itemsPerPage - 1;
            if ($last > $this->totalItems) {
                return $this->totalItems;
            }
    
            return $last;
        }
    
        public function setPreviousText($text)
        {
            $this->previousText = $text;
            return $this;
        }
    
        public function setNextText($text)
        {
            $this->nextText = $text;
            return $this;
        }
    }
    

    activate plugin.

    come to my site xakplant.ru

  • What you are trying to accomplish is not directly possible. ACF only stores the post ID of the post object field. Using WP_User_Query there isn’t any way to look at the title of that post. For this to work that post title would need to be stored in the user meta table.

    The above is possible, you would need to create an acf/save_post filter. In this filter if a user is being saved then you would get the post object field and then get the title of the post and store it into another meta_key using update_post_meta(). Then you could use this new meta_key in your search.

    The main issue with doing this is that it would not be automatically updated if the post title was changed. This means that you’d need to create another filter that runs every time a post is saved. In this filter you’d need to do a query for all users that have selected the post and then update your new field to hold the correct title.

    Your other problem is that you cannot to an “OR” relationship between the standard WP search term and a meta query. It will only return results where the search term is in one of the standard search field AND it is in the meta value. This means the you need to also alter the WHERE clauses of the user query. I don’t have any information on doing this but it would be similar to searching a post where you want to do an OR with the post content or a meta field. I’ve done a quick search but I can’t find anything on how you’d go about doing this. This has come up before here, but I don’t think it was ever resolved https://support.advancedcustomfields.com/forums/topic/extend-backend-user-search-to-custom-user-meta/

  • Is it possible?

    No, there isn’t any way to get the standard wp search to search additional posts from a relationship.

  • Fixed my single data issue also. The data I got back from my previous function looked like

    a:6:{i:0;s:3:"112";i:1;s:4:" 113";i:2;s:4:" 114";i:3;s:4:" 115";i:4;s:4:" 111";i:5;s:4:" 116";}

    Take a note to the spaces, the spaces resulted in incompatible data. To fixed this I changed the line in the function $values = explode(",", $checked); to $values = explode(", ", $checked); and now the data looked like:

    a:6:{i:0;s:3:"114";i:1;s:3:"113";i:2;s:3:"116";i:3;s:3:"115";i:4;s:3:"111";i:5;s:3:"112";}

    No spaces!

  • I have already checked the options_name table in wp_options according to the ACF FAQ. The maximum name length is 191 characters, so that’s unlikely to be the culprit.

  • @hube2

    In the above function, is it possible to get the post_type somehow?

    I am thinking to use this same field in more post_types, so it would be nice if I could do something like:

    if ('places' = $post_type) {
      $meta_query = array(
        array(
          'key' => 'place',
          'value' => $post_id,
          'compare' => 'LIKE'
        )
      );
      $args['meta_query'] = $meta_query;
    }

    I tried global $typenow but it didn’t do it.

    My other option is to create additional field groups…

  • Are you testing the query to make sure it the main query?

    That was my mistake!
    Thanks @hube2

  • @hube2 John, thanks a lot for the response and the help.

    I realized that as with Save Terms disabled – my tax_query was returning nothing.
    I enabled, re-saved the post and now tax_query works.

  • Your filter is interfering with the query that ACF is doing to get the images. What are you using for the filter? Are you testing the query to make sure it the main query?

  • These settings cause the taxonomy field to work the same way as the default taxonomy metabox that you removed. It updates the relationships of posts to terms

    Create Terms: Let’s users create new terms

    These are the ones that will give you problems

    Load Terms: Gets existing terms the post is associated with
    Save Terms: Saves the terms for the post

    With these off the only place these terms are associated are in the acf field and you must to a meta_query to get posts in a specific term

    With these turned on the value are stored in a way that will let you create wordpress term templates “taxonomy-{$taxonomy_name}.php” and use a tax_query for getting posts in a term.

Viewing 25 results - 9,126 through 9,150 (of 21,340 total)