I agree that this is PHP rather than WP question.
To bring it closer to WP I do suggest to take a look at following functionality:
- HTTP API is highly suggested for making HTTP requests;
add_post_meta()
and related meta functions to store post-specific information;the_shortlink()
function, that is suggested template tag to use for natvie short link functionality (and hook into for third party).
Related Posts:
- get php variable from functions php and echo it in theme template files [closed]
- Use AJAX in shortcode
- How to influence the information displayed on widget inside wp-admin
- Remove Container Element From wp_nav_menu() Markup
- WordPress function like is_category for subcategory? is_subcategory?
- WordPress Theme Update Action?
- Using a private method as an action callback from within a class
- Auto close (hide) custom metabox / set default state
- Does WordPress Development Mode Exist (with not minified JS)?
- WP_Query in functions.php
- wp_delete_user with username
- what is the meaning of settings_fields()
- Organize functions.php
- How to activate “Description” metabox for menu item programmatically?
- Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
- Edit the_content function
- write in functions.php
- How to set child post categories to parent post categories when updating parent post?
- get excerpt without images
- display 100 products per page on product category page [closed]
- Adding WooCommerce to a Custom Theme – not working [closed]
- WooCommerce add_action hook results in 500 error
- Advice: Template structure – php blocks in sidebar or someting else?
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- wp_get_post_terms() returns WP_Error in functions.php but in template it works
- Removing the first image in content
- Move jQuery and Migrate to footer?
- Make menu structure match page heirarchy on page parent change
- Gravity Forms field entries into wp_query loop [closed]
- Global functions on WPMU
- Remove the deleted users avatar from list
- str_replace function in theme
- is_account_page() change to page slug
- Adding to fontawesome-webfont.woff2 to boost website speed
- How to add nav menu items to a specific position within a menu
- woocommerce: change default setting > is_sold_individualy function
- Help with WP gallery function, wrap gallery in div
- set_post_thumbnail when user is not logged in
- WordPress Menuing Question :focus
- call of javascript function to external url always blocked by cors
- Can you put a condition on add_image_size() depending on the width of the uploaded image?
- Force to use STRONG users password and implement rule to prevent REUSE [closed]
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Adding an external HTML link to a post thumbnail
- Overwriting the menu break points of twentysixteen in child theme
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- Passing User_Fields to Contact form 7 [duplicate]
- How can this crude function be improved?
- help I changed one currency in woocommerce and everything is ruined [closed]
- How to run a function in every page, every device
- Which function required?
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- AJAX error handling for submit function in functions file
- get_pages() Returns Only One Item
- Custom Query Not Paginating
- Use a shortcode to display custom meta box contents
- Solved: redirect to another page using functions.php
- Getting the teaser text without overriding global variables
- add_theme_support( ‘title_tag’ ) is not showing title on index.php
- Solution dealing with Child Theme / Parent theme functions
- Problem enqueuing scripts on not single posts
- Function to pull data from user meta not working
- referencing the current user in a page i created in wordpress
- is_main_query() always returning false
- Counting posts and trigger it [closed]
- is_product_category(‘Services’) not working
- modifying every other element’s class inside while loop
- Adding Custom Body Class for Page: Shop
- Replace theme function
- How to access custom class methods from any include without using global
- Is it possible to use ‘wp_insert_post’ function within a for loop?
- save_post function keeps triggering: Warning: array_map(): Argument #2 should be an array… when restoring from trash
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- What is best practices to move the following code into a function?
- Redirect after login to current URL
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Best way to add image to recent posts widget?
- Function to draw random image from specified category destroys site logic – why?
- Issues with add_query_arg() not passing a variable
- wp_enqueue_script only works outside of action
- How can I include user meta information in the resulting array of a WP_User_Query?
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Move captions under gallery images in twenty fourteen theme
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- Get Value of Custom Field
- Undefined offset: 2
- Sorting date results from a query
- Using is_plugin_active within functions.php
- Add title & subtitle to shortcodes
- Button generate a random URL [closed]
- How to Delete Posts by title?
- How do I add functionality to images?
- Display function from functions.php in tag.php
- AJAX values converted to PHP Variables?
- function to show youtube videos within excerpt – if condition and apply_filters
- How to automatically load Google Fonts on pages only as they’re used?