Support

Account

Home Forums Front-end Issues How to Get Field in the Title

Solved

How to Get Field in the Title

  • Hello,

    i need to show field in the title of the page in the front page of website ,
    so can somebody help me ,

    Thanks,
    Wael.

  • Need more information.

    Do you mean in the <title> tag of as the displayed title in heading tag?

    Where is the field located? On the post that’s being displayed? On some other post? On an options page?

  • Hi Jhon,

    the field located on page and i need to view the field in home page like the image in the link below,
    http://goo.gl/bX8mWY

    Thanks,
    Wael.

  • there is still not enough information here? Do you have code that you’re using?

    The basic way to show a value is the_field('field_name') Maybe you should take a look at some of the documentation https://www.advancedcustomfields.com/resources/

  • i’m sorry if i can’t explain what i mean,
    but in simply i working on classifieds website and i need to put the value of the fields in the homepage with the post,
    here is the code i use

    <?php
    
    class td_module_mx1 extends td_module {
    
        function __construct($post) {
            //run the parrent constructor
            parent::__construct($post);
        }
    
        function render() {
            ob_start();
            ?>
    
            <div class="<?php echo $this->get_module_classes();?>">
                <?php echo $this->get_image('td_356x220');?>
    
                <div class="td-module-meta-info">
                    <?php echo $this->get_title();?>
                    <div class="td-editor-date">
                        <?php if (td_util::get_option('tds_category_module_mx1') == 'yes') { echo $this->get_category(); }?>
                        <span class="td-author-date">
                            <?php echo $this->get_author();?>
                            <?php echo $this->get_date();?>
                        </span>
                    </div>
                </div>
    
            </div>
    
            <?php return ob_get_clean();
        }
    }

    Thanks.

  • 
    <?php
    
    class td_module_mx1 extends td_module {
    
        function __construct($post) {
            //run the parrent constructor
            parent::__construct($post);
        }
    
        function render() {
            ob_start();
            ?>
    
            <div class="<?php echo $this->get_module_classes();?>">
                <?php echo $this->get_image('td_356x220');?>
    
                <div class="td-module-meta-info">
                    <?php echo $this->get_title();?>
                    <?php the_field('your_field_name'); ?>
                    <div class="td-editor-date">
                        <?php if (td_util::get_option('tds_category_module_mx1') == 'yes') { echo $this->get_category(); }?>
                        <span class="td-author-date">
                            <?php echo $this->get_author();?>
                            <?php echo $this->get_date();?>
                        </span>
                    </div>
                </div>
    
            </div>
    
            <?php return ob_get_clean();
        }
    }
    
  • the code it work if i’m in the same page but when i go to homepage i did not get anything.

  • I think you’ll need to get help from whoever built the framework you’re using. Not seeing it on the home page means that either you’re putting the code in the wrong place or you need to supply the post ID when getting the field from ACF, for example <?php the_field('your_field_name', $post_id); ?>. I don’t know if this value is available in that class method that you’re trying to modify.

  • if i add this code <?php the_field('your_field_name', $post_id); ?>
    i will get a static results, we need to generate the value every single time automatic in loop .

  • The reason is because $post_id does not have a value there. Like I said, I don’t know how to get the value given the code you’ve posted. This is specific to the framework you are using. I am not familiar with the framework an you will need to ask the creators of that framework how to get the post ID of the current post in the loop where this code is used.

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘How to Get Field in the Title’ is closed to new replies.