Hi Valerie
If you use one of our filters to modify the output of an element, you should be able to get the post ID by doing (recommended):
get_the_ID()
?
Otherwise, this should work:
global $post;
$post->ID; // this is the var
Let me know how you get on π
Best
-
This reply was modified 10 months, 1 week ago by
Code Amp.
Hi,
Thanks for replying.
When you say “one of your filters”, can you please give me examples of filters (exact names) I can use to modify the output of each post element displayed in the custom layout grid?
Thanks,
Valerie
I tried the following with both ways to get post id, but both pieces of code below only print out the id of the recipe search page, and don’t give the post ids of the posts displayed in the custom layout grid. Can you please tell me how to get this?
add_action( 'wp_footer', 'add_rating_below_cl_result_post_title');
function add_rating_below_cl_result_post_title(){
global $post;
$post_id = $post->ID;
logpprint($post_id);
}
and
function add_rating_below_cl_result_post_title($title){
logpprint(get_the_ID());
return $title;
}
add_filter('the_title', 'add_rating_below_cl_result_post_title',1);
Thanks in advance,
Valerie
Hi Valerie
Just before I double check this, are you on the latest version (1.4.2)?
I believe in a recent update we made these vars available in our loops – if not then I will need to track down a bug it looks like :/
Thanks
-
This reply was modified 10 months ago by
Code Amp.
In regards to the filters – you can find them here:
https://customlayouts.com/documentation/action-filter-reference/
The one you probably want is this:
custom-layouts/element/render_output
This allows you to completely replace the HTML of the element.
-
This reply was modified 10 months ago by
Code Amp.
Also, try get_the_ID()
inside this hook custom-layouts/element/render_output
and let me know if it works for you?
Yes, I’m on the latest version (1.4.2), and I’m so happy to tell you that adding my code inside the custom-layouts/element/render_output hook worked perfectly. π
I was able to use get_the_ID() within that hook just fine so no bugs to report.
Thank you so much for the amazing support and help, and of course for developing this awesome plugin. Couldn’t have done it without you.
Thanks again,
Valerie
P.S. I’m just about to write a stellar review for this plugin and give it a well deserved 5 stars. π
So glad it worked out for you π