How to remove xmlns on language_attributes()?

As you can see by the end of the get_language_attributes function there is a call to apply_filters. This allows themes and plugins to change the language attributes. In your case the two xmlns tags are added, one for facebook and one for addthis. You will have to check your plugins which ones are doing this. … Read more

How to get post URL in the_content filter?

You can do a conditional and return the post’s URL by using a get_the_permalink() in conjunction with is_single(): add_filter( ‘the_content’, ‘my_filter’ ); function my_filter( $content ) { // Check if we’re inside the main loop in a single post page. if ( is_single() && in_the_loop() && is_main_query() ) { return $content . get_the_permalink(); } return … Read more

List User order by ID in Descending order (Backend)

I first thought that pre_user_query would be that hook for the job. But I think using the equivalent of pre_get_posts, which is pre_get_users, would be suitable here. You also said you wanted to run this in admin. So we will check that before running this. function my_custom_order_users_by_id( $query ) { //Check that we are in … Read more

Plugin exceeds memory limit

The code you use also uses WordPress functions that will first load posts (and other relevant data) in memory first and cache them using object cache. So, to delete 100.000 posts, your code will try to load each post in memory and that can take a lot of memory. I am not sure how high … Read more

How to return a foreach inside a shortcode

As I said in the comment you can use buffering like this function stock_agenda() { $days = json_decode(file_get_contents(‘json_file’)); unset($days[0]); ob_start(); // start buffer ?> <table class=”table”> <thead> <tr> <th> Title </th> <th>Content</th> <th>Date</th> </tr> </thead> <tbody> <?php foreach($days as $day) { ?> <tr> <td><?php echo $day[0]; ?></td> <td><?php echo $day[1]; ?></td> <td><?php echo $day[2]; ?></td> … Read more

How to generate page content from database the right way?

WordPress is fetching current post for you, you have to only type to the right url. When you get e.g. to example.com/lorem-ipsum/ WordPress will load automatically post with title Lorem ipsum and display it using page.php template. Your page.php template should be looking something like that. <?php get_header(); ?> <div id=”content”> <?php while ( have_posts() … Read more