kizha
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Giving variable to meta_valueFor anyone having the same issue, I solved the problem by using the code below:
$author = get_post_meta( get_the_ID(), 'author', true);
instead of
$author = the_field(‘author’);
Forum: Developing with WordPress
In reply to: Giving variable to meta_valueThanks for the reply, but as I’m not so good with the technical stuff, I’m not sure I understand. I haven’t used PHP before but I believe you’re saying that the query itself is wrong?
if so, like I said when I specify the author myself by typing in ‘meta_value’ => ‘Paula Hawkins’, for example. But when I put in $author or even leave it empty, it shows books by all authors I have instead of the one specific to the current book’s page. So I’m wondering how I can assign the function “the_field(‘author’);” to the meta value.Forum: Developing with WordPress
In reply to: Giving variable to meta_valueHello Ian, thanks for the reply, but the variable isn’t null because when I echo it, it shows the author of the book correctly. My bad for not sharing this part of the code in the first place:
<?php
$author = the_field(‘author’);
echo $author;
//code that shows books by same author
$posts = get_posts(array(
‘numberposts’ => -1,
‘post_type’ => ‘book’,
‘meta_key’ => ‘author’,
‘meta_value’ => $author,
‘post__not_in’ => array( $post->ID )));
Yes, I believe the problem has been solved! Thank you.
Hello again, I’m a beginner to PHP so I had to first look up how to use action hooks, after trying some code out it deleted the page that the form itself was located on instead of the post that was submitted through the form :/
Thank you Adam.
Could the support team please keep this topic open until I get a chance to try out what you suggested on the weekendIm using the forminator ‘Hidden’ form field with the ‘embed post/page ID’ option selected yes. After submitting the form a new post is created and i want the wordpress post ID that is saved into the database of that newly created post.
To further explain incase needed, im trying to make a book reviewing website/app im using the form as a way for users to enter in books which dont already exist on the website/in the database. However im trying to use a custom field ‘ISBN’ to act as a primary key so that users cant enter the same book twice. To implement that, ive redirected the user to another page where theyre told if their entry is successful or not which is where im using GET to get the isbn and post id from the form so i can check if the isbn already exists and then delete the newly created post because it has already been added before. Now im able to delete the entry from the forminator database but not the wordpress database because im not getting the post id that shows up in that database. Also this is a problem for me because the copies of the books are showing up on my homepage even when ive deleted them from forminator database. (Im using cpt and custom template to display them btw). I dont know if all of that explanation was useful but i hope it helps understand my problem
Yes, you got my question right. Thanks for the detailed response anyway!
Hello,
I’m having the same issue but as I’m not familiar with PHP or coding that much, I’m having a hard time following. I’ve added the above code to the page I want, but it keeps showing the else option. I’m not sure what I’m supposed to put in my parameter, how does it know that for example, ‘name’ is referring to the name value in the form?Edit:
I have also tried the following:
https://premium.wpmudev.org/forums/topic/forminator-pro-transfer-fields-to-the-success-page/#post-3708751
but I can’t access the passed form info. since I still get the “else” echo message.- This reply was modified 4 years, 1 month ago by kizha.