How to get widget content in Wordpress based on it's ID?

I need to parse widget content based on it's ID. But a widget works like a function that pulls data based on it's arguments, right? So when I pull the widget data, I can only get it's arguments, not the actual output. How can I parse the widget content based on it's ID? Example code: // Update widget rounds automatically function automatize_games_rounds($instance, $widget, $args){ // Check if there is a caption if (isset($instance['caption']) && !empty($instance['caption'])) { // If there is, …
Category: Web

Get post / page ID from ACF Link field

I'm trying to recieve post ID from link using ACF link field: <?php $link = get_sub_field('offer_link'); $id = get_the_ID(); if( $link ): ?> <a href="#post-<?php echo $id; ?>" target="<?php echo $link['target']; ?>"><?php echo $link['title']; ?></a> <?php endif; ?> but instead of ID of link I get the ID of current page. How should it be done?
Category: Web

WordPress plugin Write User/staff ID as the same as the WordPress User ID

I have a question in regards to a WordPress plugin (Bookly) that creates a Staff ID for an already created WordPress user, and hopefully, somebody may be able to help me with. Currently Bookly adds the Staff ID incremental so each new staff ID would say Staff ID:4 then the next 5 then 6 etc, I'm looking for some code that would take the current WordPress user's ID and add that ID as the Staff ID for that user when …
Category: Web

How do I get the current edit page ID in the admin?

Most solutions I found are for front-end use. This is for a plugin, so the all activity is in the back-end. How do I get the page ID that's being currently use(edited) in the admin? Note I'm out of the loop. I just need to get the ID of page(not posts) that I'm currently seeing in the back-end.
Category: Web

Get post attachment with post id

I have a form where user can upload a file, which creates a post with an attachment. I would like to get this attachment with post id, because this is the only thing I have in my case. Is it possible ? Thank you, ArbreMojo.
Category: Web

Is it possible to have dynamic post id # in add_menu_page()?

I use the add_menu_page function in my custom theme builds but when I export my local copy of the site and import it in the production site some of post id numbers change and I have to update this function manually (ie: in the code below: ?post=8, ?post=8, ?post=10). Is there a way to have these numbers be dynamic? function custom_admin_menu_links() { $user = wp_get_current_user(); if ( ! $user->has_cap( 'manage_options' ) ) { add_menu_page( 'Home', 'Home', 'edit_posts', 'post.php?post=6&action=edit', '', 'dashicons-admin-home', …
Category: Web

Why is my insert row only inserting the final row from the loop into the database rather than just inserting one

<?php session_start(); if(is_user_logged_in()) { global $wpdb; $id = get_current_user_id(); $recoveryID = null; // $results = $wpdb->get_results('SELECT * FROM wp_recovery_details where not exists (select driverID ,recoveryID from wp_recovery_bids where driverID='$id')'); // $results = $wpdb->get_results('SELECT * FROM wp_recovery_details'); // // EXISTS (select driverID ,bidAmount from wp_recovery_bids) // output data of each row foreach ($results as $row) { // $recoveryID = $row->recoveryID; // $result = $wpdb->get_results('select * from wp_recovery_details where not exists(select driverID from wp_recovery_details where recoveryID ='$recoveryID' '); // if(count($result) > 0){ …
Category: Web

How to get Previous Visited Page Information

I want to Change for Customized my Contact Form based on Previous URL Visited or We ca say I want to Dynamically Change the Values of Contact Form based on Previous URL Visited. So I had searched and tried various best possible option to customized it like Session, Cookies, Global Variable, wp_get_referer, HTTP_REFERER & url_to_postid but it didn't help me. So I am looking for Previous Visited Page ID or Custom Field Values of Previous Visited Page. Help Please.
Category: Web

How to get ID of images used in gallery?

How to get ID of images used in gallery? Using $gallery = get_post_gallery_images( $post ); I only get a string with thumbnails url, without image ID which is needed for basically everything. https://codex.wordpress.org/Function_Reference/get_post_gallery_images (In the end I am looking for a way to get image object for all images used in gallery, I am searching in Codex but I can't find it)
Category: Web

get_the_ID() in the footer returns wrong value

I'm using get_the_ID() in footer.php but it returns a wrong value. It might come from any of the plugin which is altering The Loop without resetting it after with wp_reset_postdata() as mentioned in $post->ID and the_id() always return the wrong value. Indeed the page shows a list of recent posts, etc. so this might modify the current Loop. If I can't modify this (because of third party code), how to get the ID of the current post in the footer …
Category: Web

Give ID to divs inside the loop

I'm trying to make this code work on my WordPress site: https://codepen.io/eksch/pen/xwdOeK It is a simple code so that each menu item receives the active class when the user scrolls through the page, indicating where he is. But I realize that to make it work it's necessary to give ID to the divs. My site is made entirely from blocks, which are called in the body of the site via the_content(). Wordpress blocks do not allow me to give ID`s …
Category: Web

get all page IDs from wp_list_pages

I am looking for a way to output all page IDs from the following menu: <?php wp_list_pages('depth=1&exclude='3,5,11')); ?> Only top level pages needed, therefore the 'depth=1'. Any help appreciated.
Category: Web

How to get the post's parent ID?

I have a template which outputs the blog posts (Blog Page), I open one of the posts which use single.php template, Now how can I get the ID of it's parent which is the (Blog Page)? I should say that I want to use this ID to get the meta box value of the blog page in single.php. The same goes for a custom post type, let's say 'project', Where a page template list the project's posts (Projects Page) and …
Category: Web

Give custom page template a custom post ID

I created several custom pages in WordPress. One displays real estate listings. When you click on the listing it opens into another custom page I created. The problem is no matter which listing I click on the custom page always has the same post id. This is preventing me from being able to allow users to save their favorite listings as most favorite plugins use the post id to identify a page. Is there a way to give custom pages …
Category: Web

Bookmarking custom template pages which all have the same page ID

I have a custom page I created in WP which displays different real estate listings. Since it is a custom page the page ID is always the same. For example both of these URLs display different properties but both have the Page Id of 11. http://geekoutaustin.com/theme1/property/?id=53f0a3a9ec0c542dfe6000a06f12b2c2&wpf28382_5=3300173 http://geekoutaustin.com/theme1/property/?id=03ef31c711d997f0c4e36358da1bac5d&wpf28382_5=2351429 I want to add a bookmarking plugin to give users the ability to save listings to their favorites. I have installed just about every plugin available and they all operate the same way …
Category: Web

Does an article (post) id ever change?

So I'm working on a plugin for wordpress, and a novice at it as well. I need to use the ID of a wordpress post, or blog article rather, as a unique reference id, or lets say in database terms, a Unique or Primary key. Does the ID ever change on a blog? Extra background info..: I'm using this function to get the id of a unique post: the_ID(); Also, the URL of a blog post on my test site …
Category: Web

How to get ID of Edit User page during wp_handle_upload_prefilter, whilst in Media picker?

I have an Advanced Custom Fields field group on Edit User pages (user-edit.php), containing an Image field (avatar). I aim to rename that uploaded filename to match the username of the on-page user. My current code uses wp_handle_upload_prefilter to catch the upload, and, to ensure the rename does not happen to all WP file uploads, I think I need to check that the upload field in question is my specific ACF Image... In the below code, (1) I can successfully …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.