I’m not sure what you’re doing with the above script, but here are some random suggestions:
- Avoid using the
root
user, for security reasons create another database user with less powers. - Avoid using deprecated
mysql_*
calls. - Use
WP_Query()
orget_posts()
instead of hardcoded SQL queries. - Use global
$wpdb
object if you really must use hardcoded SQL queries. - Remove the
<?php
…?>
spam - Try doing this within WordPress itself, instead of creating an extenral
script.php
file. - You don’t seem to be using the
$blog_url
,$query_result
,$num_rows
, … variables. - There are other ways like WP REST API, XML-RPC, RSS, JSON
Related Posts:
- Add inline HTML to posts published within last 24hrs
- meta_query not working properly
- Show one post per author and limit query to 8 posts
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Order posts by meta value and Date
- WP_Query with offset and ‘orderby’ => ‘rand’, offset not working
- Reset WordPress Post Query to default
- 2 column recent post query not respecting float right [closed]
- How to add a recent post function to a text widget I created for practice?
- date_query problem
- order by numeric value for meta value
- numberposts? showposts? posts_per_page?
- $GLOBALS[‘wp_the_query’] vs global $wp_query
- Some doubts about how the main query and the custom query works in this custom theme?
- How to query posts based on lat-lng coordinate as post meta?
- How to query only for products with status “in stock” in WooCommerce? [closed]
- WP_Query displaying ALL posts
- Does WordPress sanitize arguments to WP_Query?
- How to trigger 404 for custom query var?
- How to combine tax_query and date_query in WordPress
- How to get any tag ID
- wp_query display posts from same category of the post
- Targeting specific pages in the loop
- WordPress custom archive page
- Include Sticky Posts in Page Post Count for custom query
- Query sticky posts with thumbnails
- Show all parents and children in custom post type in right order
- Why is this coming back as null? Thats wrong. There is one post
- Retrieve featured image (thumbnail) url from multiple posts with one query
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Can you order posts from wp_query by two custom meta fields?
- Retreaving all images attached to current post
- wp_query() get_col error
- Pagination working everywhere but the index page
- How to select posts from one category but exclude posts in another category?
- How do I search inside specific taxonomies in WordPress
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- How can you get first post, last post and post count in a category?
- What’s the purpose / logic of split_the_query in WP_Query->get_posts
- WP_query posts closest to todays date
- if statement in wp_query arguments
- Need wp_query to return all children and grandchildren
- How to use offset in WP_Query
- difference between like ‘%%%var%%’ and ‘%var%’
- WP Query Category Atribute Not Working
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- new WP_Query to get max price meta value not working
- wp_query should show stickies first
- WordPress custom post type with meta – how to retrieve with wp_query
- Pagination links missing for first link (1) and previous button? How to get pagination links to work?
- wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’
- Order by meta value (numeric value lower to higher)
- WP_Query with different postmeta filter for each categories
- Wp query show post by author name or post title or post content
- wordpress ajax relationship query
- Shouldn’t I be able to modify the main query by this filter?
- Admin Page Post Id wp_reset_postdata not working
- Multiple queries and performance – wp_query
- WP_Query for a taxonomy with different taxonomy types
- Display single most recent post in category on every page of category archive
- Executing query_posts after wp_insert_post
- Redirect Search to Form When No Product Results Are Found
- Show menus to one admin username
- inserting content of 1 Post to in another with a template hierarchy
- get_posts custom field
- wp_query posts with custom fields number smaller than
- is_404() – where does this get set?
- Max Posts and Memory Limit
- WordPress | WP_Query does not return anything with s=a
- WP_Query Pagination
- WP_Query orderby
- Using Ajax and WP_Query to load more posts on category page fails
- I have problems with the search query using multiple post types
- How to check if logged in user have pending custom post?
- How can I re-query post_type and rewrite the url?
- Different query result on local and server
- meta_query compare > not working
- How can I show only last year posts in wordpress archive?
- WP_Query about meta_key and its array value
- I can’t get post based on its postmeta value and key
- Change database image location for transportability
- Combine Tax Archive and Meta_Query in WP_Query
- Get posts by birthday
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Paginate nested query of child posts
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Issue in If else condition [closed]
- Pagination not working with WP_QUERY
- Get Current CPT taxonomy category in shortcode
- Custom Content Slider stop duplicate
- Extract video content from post to display on front page
- Sort Posts with custom meta key by default which is currently set as optional
- wp_query pagination links producing 404
- Pagination problem with multiple loops on the same page
- Carousel slider with WP_Query to show 3 posts on each slide
- how to use transient method?
- WP_Query – meta fields numeric
- How to query posts from single post format on Genesis framework
- How to replecate the _fields parameter in custom REST api endpoint
- WP Query returning all posts when Meta_query is null