Customization – Meta query for custom post type that is ignored in the main query

I looked through the Interwebz but couldn't find a solution.

I am creating a website with custom post types where posts also contain custom post meta (via ACF).

I am creating an archive file and want to implement some filters (filter post by category and two different custom fields.

To even display the custom posts (called "mowcy") in the category template, I added this snippet to my function file:

functions.php

function custom_post_type_cat_filter($query) {
   if ( !is_admin() && $query->is_main_query() ) {
      if ($query->is_category()) {
      $query->set( 'post_type', array( 'post', 'mowcy' ) );
      }
   }
} 

Now I have uploaded a simple archive template to see how it works:

archive.php


This is where the problem begins:

If I specify the arguments in the code and use a custom query to display custom posts with a certain custom field value "EN" (an ACF "Languages" field with multiple check boxes for different languages), it works fine:

// Specify query parameters
$args = array(
    'post_type' => 'mowcy',
    'meta_query' => array(
        array(
            'key'     => 'languages',
            'value'   => '"EN"',
            'compare' => 'LIKE'
        )
    )
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) // ... Beginning of the loop

However, when I print the same arguments to use in the URL (using http_build_query with $ args) it looks like this:

post_type=mowcy&meta_query%5B0%5D%5Bkey%5D=languages&meta_query%5B0%5D%5Bvalue%5D=%22EN%22&meta_query%5B0%5D%5Bcompare%5D=LIKE

After archive.php has been reset to use the main query and URL parameters again and the above parameters have been used, meta_query is completely removed from the query and only shows all posts of the user-defined type "mowcy". I can add a category parameter to the url and it works fine, but meta_query is still completely ignored.

What am i missing Does the query feature ignore meta_queries for custom post types by default? How can I fix it?

As I said at the beginning, I also plan to filter the posts by an additional second custom value (i.e. a second additional meta_query). Will this be an additional problem (when looking for a solution I saw a few mentions that in such a case you would have to manually merge two meta queries)?

Thanks in advance for any kind of support.

wp insert post – How do I get the current permalink in the wp_insert_post hook?

I have two terms in the category taxonomy: Fashion and travel, When a post is in fashion and I switch to travel and save. The permalink shows the old format with fashion instead of travel. If I save again, the correct permalink will be displayed.

Dig deeper in get_permalink() I found out that get_terms(array('taxonomy'=>'category','object_ids'=>$post_id)) gives me fashion back instead of traveling. Unless I'm saving again. I tried wp_cache_flush() and clean_post_cache($post) without success. I checked the database after the first save and the table wp_term_relationships shows the right one term_taxonomy_id,

Here is the simple code:

add_action( 'wp_insert_post', 'cm_wp_insert_post', 10, 3 );

function cm_wp_insert_post( $post_id, $post, $update )
{
    $url = get_permalink( $post );
    // $url shows the old permalink until the post is saved again
}

Thumbnail view of the cutting post without falsifying to cut it to dimensions

I'm trying to crop my thumbnail in my loop. I'm having some problems cropping with codes. Some images appear either in width or in height. Here is my code
css

.imgholder {float:left;margin-right:20px; margin-left:20px;height:240px;width:240px;}

loop

 'imgholder')); ?>

When I see the & # 39; big & # 39; in & # 39; Thumbnail & # 39; change from above, it works perfectly. please help
Thank you very much

Post your article on the Google News website with a backlink for $ 10

Post your article on the Google News website with a backlink

I will post your article on Google newswith a Dofolow backlink.

Details :
Your article will stay on my website for a lifetime.
Your article will appear in Google News.
You will receive a dofollow backlink from our website.
You can share the picture with the article.

Note:

Item should be unique.
Article should contain min. 300 words.

8 – Guzzle POST HTTPS requests return 403. Only forbidden if they are called in PHPUnit tests

On the one hand, I have a remote Drupal 8 (8.8.1) that is operated via HTTPS and has the following endpoint:

MODULENAME.get_notify:
  path: 'MODULENAME/get-notify'
  defaults:
    _controller: 'DrupalMODULENAMEControllerMODULENAMEApiController::get_notify'
    _title: 'Get notification'
  methods:  (POST)
  requirements:
    _access: 'TRUE'

On the client side, I have a Drupal 8 (8.8.2), which is provided via HTTPS and sends a notification via the Guzzle library. This Drupal is local to my computer and is provided via DDEV. Here is the Guzzle petition, which is in a custom module:

$options = (
  'headers' => ('Content-Type' => 'application/json'),
  'json' => $jsonArray,
  'timeout' => 15,
);
$response = $this->httpClient->post($url, $options);

The system works well, except that when running PHPUnit tests (BrowserTestBase) on the affected module, the POST query always returns the following error:

Client error: `POST https://SERVER_DOMAIN/MODULENAME/get-notify` resulted in a `403 Forbidden` response'

Any idea why I'm getting this error message?

Database – Update the custom post type taxonomy using SQL Query

In the following I will explain some of my tasks and how I would like to process this request.

  1. I imported all & # 39;posts& # 39; from my other website in & # 39;posts& # 39; on my current website.

  2. On the new website, I have a custom post type called "Recipe". With the following query I can transfer all "Posts" with the category "Recipes" / "Slug" into the user-defined post type "Recipe".

Here is the code:

UPDATE  `wp_posts` p 
    LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID
    LEFT OUTER JOIN wp_term_taxonomy x ON x.term_taxonomy_id = r.term_taxonomy_id
    LEFT OUTER JOIN wp_terms t ON t.term_id = x.term_id
    SET  p.post_type =  'recipe'
    WHERE p.post_status = 'publish'
    AND p.post_type = 'post'
    AND t.slug = 'recipes';

This moved all of my posts to my custom post type that has a & # 39; recipe & # 39; slug associated with (Which is what i want) – The - Hyphens are the categories that have not been transferred.
Enter the image description here

I'm stuck here, I have the following question:

UPDATE `wp_term_taxonomy` SET `taxonomy` = 'recipe-categories' WHERE `taxonomy` = 'category';

This query transmits and fills in all taxonomies, but then all posts in my "Posts" are removed from their categories.

question::

Here's the ultimate goal: Select custom recipe post type where taxonomy is 'category' and change it to 'recipe-categories' – Is that possible? I want to change the taxonomy in "Recipe Categories" of ONLY posts that are associated with a custom "Recipe" post type.

Testing – 8 – POST HTTPS requirements for Guzzle POST 403 Only forbidden if called in PHPUnit tests

On the one hand, I have a remote Drupal 8 (8.8.1) that is operated via HTTPS and has the following endpoint:

MODULENAME.get_notify:
  path: 'MODULENAME/get-notify'
  defaults:
    _controller: 'DrupalMODULENAMEControllerMODULENAMEApiController::get_notify'
    _title: 'Get notification'
  methods:  (POST)
  requirements:
    _access: 'TRUE'

On the client side, I have a Drupal 8 (8.8.2), which is provided via HTTPS and sends a notification via the Guzzle library. This Drupal is local to my computer and is provided via DDEV. Here is the Guzzle petition, which is in a custom module:

$options = (
  'headers' => ('Content-Type' => 'application/json'),
  'json' => $jsonArray,
  'timeout' => 15,
);
$response = $this->httpClient->post($url, $options);

The system works well, except that when running PHPUnit tests (BrowserTestBase) on the affected module, the POST query always returns the following error:

Client error: `POST https://SERVER_DOMAIN/MODULENAME/get-notify` resulted in a `403 Forbidden` response'

Any idea why I'm getting this error message?

How to post comments using the WP Rest API in Laravel

I am trying to post comments with wp rest api in laravel.
Here is my code.

Great:

public static function postComments($postId, $author_name, $author_email, $content){

    $url = config::get('app.WP_BASE_URL') . '/wp-json/wp/v2/comments?post='.$postId.'&content='. $content;

    $params = (
        'post' => $postId,
        'author_name' => $author_name,
        'author_email' => $author_email,
        'content' => $content
    );

    $data = Wpapi::curlPostRequest($url, $params);

    return $data;

}

controller:

public function postComment(Request $request){

  $id = $request->input('id');
  $author_name = $request->input('name');
  $author_email = $request->input('email');
  $content = $request->input('comment');

  $data = $request->validate((
  'name' => 'required|max:255',
  'email' => 'required',
  'comment' => 'required',
  ));

  $postComment = Wpapi::postComments($id, $author_name, $author_email, $content );



    if($postComment){
      echo "Success";
    }
    else {
      echo "Failure";
    }

}}

Any idea where I'm wrong?