Why are my queries interfering with the global post variable?

$the_query->the_post(); is populating the global $post with each post in that loop. On front-end queries, you’d normally call wp_reset_postdata() after running a secondary query loop, but that doesn’t work on the admin side. Use get_posts instead of WP_Query, and iterate over the results with a foreach loop- $my_posts = get_posts( $args ); if( !empty( $my_posts … Read more

Problem with removing plugin action

What you’re doing will only remove an action added in a static method of class. From https://codex.wordpress.org/Function_Reference/remove_action If an action has been added from within a class, for example by a plugin, removing it will require accessing the class through a variable that holds the class instance. add_action( ‘wp_head’, ‘remove_my_class_action’ ); function remove_my_class_action(){ global $my_class; … Read more

Setup wp_schedule_event within a custom plugin

First of all: if you haven’t read it already, please check the official documentation on WP-Cron. The problem in your code is this line add_action( ‘setupCronJob_whatToMine’, ‘setupCronJob’); You’re defining a new action setupCronJob_whatToMine and add the setupCronJob method to it. But as this is a custom action you just created, it will never be called … Read more

Text only version of website [closed]

If you wanted to remove all colorful text from your site, you could use a global CSS rule, as in * {color:black !important; background-color:white !important} which should turn all text to black on white background. (The ‘*” should apply to all CSS elements.) That wouldn’t get rid of images or other things, so you might … Read more

Fullscreen Video/GIF Intro

The following code uses HTML5 Video, with the muted & autoplay attributes set. It takes the video, which I uploaded through the media gallery and displays it fullscreen. I’m using a script that detects when the video is done playing, then it fades out and is removed from the DOM. HTML <div class=”fullscreen-bg”> <video muted … Read more

Access WP_REST_Server from within plugin namespace

WordPress (version 5.0) doesn’t use namespaces for it’s classes, so try to use the global one: \WP_REST_Server to avoid assuming it’s in your custom namespace. One of the reason for this is that WordPress supports PHP 5.2.4+ that doesn’t support namespaces. The minimum is PHP 5.3.3+, if I remember correctly, to support it. Later this … Read more

How to create multiple database tables on plugin activation?

Why only the second? Because dbDelta() supports CREATE TABLE table_name format only. I.e. Exactly “CREATE TABLE” followed by (one space and) the table name. More specifically, dbDelta() uses this regular expression pattern: CREATE TABLE ([^ ]*) when parsing the queries into an array indexed by the table name; i.e. array( ‘table_1’ => ‘query’, ‘table_2’ => … Read more

changing posts layout in ultimate member profile plugin

Here is some basic CSS which would help make things a grid on Desktop and stacked on Mobile: .um-profile-body.posts.posts-default { max-width: 100%; padding: 0 15px; } @media (min-width: 768px) { .um-profile-body.posts.posts-default { padding: 0; } } .um-ajax-items { display: grid; grid-template-columns: 100fr; grid-template-rows: auto; margin-bottom: 15px; grid-gap: 15px; } @media (min-width: 768px) { .um-ajax-items { … Read more