I created custom post type and custom taxonomy. But I use ACF, and is need to get ID of current page Post type is 'objects'. Custom taxonomy is "objects_category". And page name taxonomy-objects_category.php
This code no works
$two_cols_catalog_left = get_field('two_cols_catalog_left');
echo $two_cols_catalog_left;
But this code works
$two_cols_catalog_left = get_field('two_cols_catalog_left', 47);
echo $two_cols_catalog_left;
47 - is ID of current page.
But is need to type
$two_cols_catalog_left = get_field('two_cols_catalog_left', $page_id);
echo $two_cols_catalog_left;
How is possible to get ID of current page?
I created custom post type and custom taxonomy. But I use ACF, and is need to get ID of current page Post type is 'objects'. Custom taxonomy is "objects_category". And page name taxonomy-objects_category.php
This code no works
$two_cols_catalog_left = get_field('two_cols_catalog_left');
echo $two_cols_catalog_left;
But this code works
$two_cols_catalog_left = get_field('two_cols_catalog_left', 47);
echo $two_cols_catalog_left;
47 - is ID of current page.
But is need to type
$two_cols_catalog_left = get_field('two_cols_catalog_left', $page_id);
echo $two_cols_catalog_left;
How is possible to get ID of current page?
Share Improve this question asked Feb 2, 2021 at 4:27 DenisDenis 1012 bronze badges 2 |1 Answer
Reset to default 0$term = get_term_by( 'name', 'Дома 5, 'category' );
echo $term->term_id;
get_field
without a post ID parameter you need to be within the "loop". So ensure you've initiated the loop when you're using it and you wont need to manually get the ID. – Paul G. Commented Feb 2, 2021 at 9:37