Shariq Khan
Forum Replies Created
-
GenerateWP works fine. There is something else going on here.
Do you have debug logs enabled on your site?
Here is how you can do it.
Forum: Fixing WordPress
In reply to: Unable to see features imagesAre the images visible in the post edit screen?
Forum: Developing with WordPress
In reply to: change src attribute of shortcode based on user clickWhat is the code you’ve written till now.
Forum: Fixing WordPress
In reply to: Unable to see features imagesCan you describe your issue in a bit more detail?
What do you mean by “uploading my old post from my database”?
Do you mean you restored the site from an old backup?Forum: Fixing WordPress
In reply to: Passive listener issue in gtmatrixThere are a couple of JavaScript issues with your site. You should fix them first.
For example, this code:
<script type="application/ld+json"> {"@context":"https://schema.org","@type":"LocalBusiness","name":"Bus Rental Dubai & Sharjah with Drivers: Transport Services, Chauffeur, Coach Rental", ... ...
is nested inside another
<script>
tag, which is incorrect.
You shouldn’t nest one<script>
tage inside another<script>
tagForum: Fixing WordPress
In reply to: Irrelevant Pages Created Automatically@shridsan2010 Could it be because of the caching plugin (Autooptimize) you’ve installed?
Forum: Fixing WordPress
In reply to: WP_POSTS not workingDo you mean that before you updated your WordPress version (from 4.4.12 to 5.x) you had 5000+ posts, and now you can see only 2?
Can you actually check in the database wp_posts table the status of the posts that don’t appear on wp-admin/posts section?
Is it MORE efficient to ask PHP to sort the results and then just pick the first result of the array?
In this case, it will be MySQL that will be doing the sorting. So you are offloading the task of sorting to mySQL , instead of having PHP do it. And will be a bit faster, compared to let PHP do the sorting.
BTW could you just remind me how to access the first post?
Try this:
$loop = new WP_Query( $args ); $posts = $loop->posts; $first_post = $posts[0];
The problem is in your
get_post_meta
.Your code is:
get_post_meta( $post_id, 'wpcf-external-client-id', true );
In the first parameter, you have incorrectly passed
$post_id
which is the ID of the newly created post.
You should pass the ID of the post in the loop. So, useget_the_ID()
instead.Sidenote:
1. You should usewp_reset_postdata()
after the while loop2. You could also have the WP_Query so that the results are displayed in descending order of the value of the meta field.
$args = array( 'post_type' => 'auction-client', 'post_status' => 'publish', 'meta_key' => 'wpcf-external-client-id', 'orderby' => 'meta_value_num', 'order' => 'DESC' );
This way the first post in the loop will be the one with the highest value of ‘wpcf-external-client-id’. So you won’t need to loop through all the results; you’d be able to use just the first one.
- This reply was modified 3 years, 9 months ago by Shariq Khan.
function set_external_client_id( $post_id, $post, $update ) { if ( wp_is_post_revision( $post_id ) ) { return; } if ( 'auction-client' == $post->post_type ) { if( !$update ){ $external_client_id = 1234; update_post_meta( $post_id, 'wpcf-external-client-id', $external_client_id); } } } add_action( 'wp_insert_post', 'set_external_client_id', 10, 3 );
Forum: Fixing WordPress
In reply to: Theme error in console with multiple themesOut of curiosity, have you assigned a menu to the location “Primary Menu” (WP Admin => Appearances => Menu)?
Forum: Fixing WordPress
In reply to: Theme error in console with multiple themesCan you share the URL of your website? Its very hard to figure out whats happening without actually looking at the site
Forum: Developing with WordPress
In reply to: Doable to display comments from a different site?You have 2 options here:
1. Iframing the comment area of SiteA on SiteB
2. Write custom code to fetch the comments from the post on SiteA, and display
them on SiteA. You will need to connect to SiteA using WP REST API.Forum: Fixing WordPress
In reply to: Theme error in console with multiple themesWhich theme? I dont see it in the ‘twenty twentyone’ theme
Forum: Developing with WordPress
In reply to: Kill custom fields on back endI am not sure the drop down that says ‘custom fields’ on the page’s back end will go away
It is not advisable to look for bulk deleting the custom fields unless you are absolutely sure of the source that created the custom field.
The CFs could have been created by multiple plugins and themes.You can however hide the ‘Custom Fields’ dropdown in the admin backend.
For that go to the backend, click on 3 dots in the top-right corner, and select ‘Preferences’ from the menu that comes up.
(see the screenshot here)A lightbox will then appear, which will have ‘Custom Fields on the very bottom.
( See the screenshot here)Unselect the checkbox that says ‘Cstom Fields’ and you are good to go