How to properly reset a nested WP_Query query

I’m missing something here. What’s the proper way to reset a query so that it doesn’t interfere with any other queries it may be nested in? This is the kind of result I’m going for: Main page This is the main page content. Now let’s display some custom nested queries. Outer page 1 Inner post 1 Inner post 2 Outer page 1 content continued… Outer page 2 Inner post 1 Inner post 2 Outer Page 2 content continued… …etc. But I can’t get the Outer Page X content continued part…

get_terms (or tax_query) for term of current post?

I’ve seen many solutions but none seem to work for me… I’ve got a grid off the loop/content on single.php that renders the whole grid as is, so I use the function as below which works fine, but only if I specify the exact taxonomy term (client-1). function my_query_args($query_args, $grid_name) { if ($grid_name == ‘client-grid’) { $query_args[‘tax_query’] = array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘client-1’, ), ); } return $query_args; } add_filter(‘tg_wp_query_args’, ‘my_query_args’); But I want the term of the current post instead so I thought…

How to run select query of post with category and tags?

I want to fetch multiple posts with categories and tags currently I’m using this query: $pagesize = 20; $pageNumber = 1; $mysql = mysqli_query($con, »SELECT p.post_title, p.ID, p.post_content, p.post_date, p.post_name as url, t.name as category_name FROM wp_posts p, wp_terms t, wp_term_relationships r, wp_term_taxonomy tt WHERE p.post_status=’publish’ AND tt.taxonomy = ‘post_tag’ AND p.id=r.object_id AND r.term_taxonomy_id=tt.term_taxonomy_id AND tt.term_id = t.term_id ORDER BY p.post_date desc LIMIT « .(int)($pageNumber*$pageSize). », ».(int)$pageSize. » ») or die (« error ».mysqli_error($con)); The mysqli-connection works. But when I run this code, I only get a blank page. How can I fix this? Source: https://wordpress.stackexchange.com/feeds

Update to functions.php not showing in dashboard

Some time ago, I added the following lines to my custom theme’s functions.php file, in order to allow authors on my site to edit posts and drafts from all users: function add_theme_caps() { $role = get_role( ‘author’ ); $role->add_cap( ‘edit_others_posts’ ); } add_action( ‘admin_init’, ‘add_theme_caps’); It worked as expected. However, I now no longer want that functionality. I have removed those lines from my functions.php file, but authors can still edit all of the posts on the site. It’s been a few hours since I updated the functions file in…

I want to update my user meta table

I have a form with the fields name, address, class, and age. When I enter a new registry, the name field gets updated in the table wp_users. Once the ID is saved, I am trying to update the user meta fields such as address, which is not happening. Below is my PHP code. Please Help me: <?php $userdata = array( ‘user_login’ => $_POST[‘usname’], ‘user_pass’ => $_POST[‘passw’] // When creating an user, `user_pass` is expected. ); $user_id = wp_insert_user( $userdata ) ; //On success if ( ! is_wp_error( $user_id ) )…

Displaying subcategories and then posts in taxonomy template

I have a custom post type ‘downloads’ which i have a have a custom template set up to get terms of to begin with. Im now trying to set up my taxonomy template so that it displays sub-categories if there are any, but if not to show posts for that term. Below is what my taxonomy template includes so far and this works fine to the point that it displays the child categories, but it doesnt then show the posts for that category at the end. Id like it so…

My WP_options db rewrite_rules Does Not Work

On my site, I have my own custom php file that handles URL GET requests. For example, at mysite.com/?burger=WellDone, it will query my db and display a page with all burgers with « WellDone » in the appropriate db field. What I am trying to do is make it accessible via mysite.com/burger/WellDone, and after 5 hours straight, have been unsuccessful. I have tried plugins, I have tried rewriting the htaccess, I have tried denying write permission to htaccess, and at current state, I am using a « rewrite » plugin by takien. Before the…

Extremely slow pageload for long post when using the_content?

My WordPress site has quite a few long posts that slow down page loading time exponentially. This only happens when using the post_content, for example, when using the the_content() and get_the_excerpt() functions. I ran some tests with the Query Monitor plugin. Load time is in addition to the page’s base loading time without the_content(). . Post 1 (Extremely long) Characters: 176223 Load time: +9 seconds . Post 2 (Long) Characters: 67203 Load time: +2 seconds . Post 3 (Average Length) Characters: 32827 Load time: +0.25 seconds . It seems that…

Hacked WordPress website /Homepage redirect

I am very sorry about the length of the post, please bear with me as I am going to try and list everything I’ve done so far. I am dealing with a hacked WordPress site which had been left without updates for quite a while now and the passwords were weak.. Also, no backups. The website uses Enfold Theme. So here goes! I’ve deleted most of the plugins. Among the ones that remain are Fastest cache, which was there, plus a few security plugins which I’ve installed. There are a…

WordPress JSON API returns normal site page in html. How do I get it to give me JSON?

For example, entering http://mywordpresswebsite.example.com/?json=1 into the browser loads the main site html, the same as omitting the json querystring variable: http://mywordpresswebsite.example.com/ The JSON API is activated. I have tried reactivating and deactivating, checking .htaccess file settings, and deactivating all other plugins. None of those have made much difference so far. Source: https://wordpress.stackexchange.com/feeds