0

I want to send a variable with a url and get the value and insert that value to a variable.

<a href="domain/newsletter-by-year?year=2020">GO TO THE NEWSLETTER FROM 2020</a>

ang get it in this url

https://domain/newsletter-by-year?year=2020

This is my wpquery

    /* Template Name: newsletter_by_year */

$year = $_GET["year"];

$args = array(
    'post_type' => 'post',
    'category_name' => 'news-letter',
    'posts_per_page'    => 10,
    'date_query' => array(
        array(
            'year'  => $year,
        ),
    ),
);

$myQuery = new WP_Query($args);

but im getting a 404 page.

2 Answers 2

0

Make sure that the page template is applied to the correct page and you are accessing the correct URL

and then go to the Settings > Permalink and save permalinks one or two times.

That should clear the older rewrite rules and make the new page template work instead of sending you to the 404 page

1
  • Thanks my friend, I just had to changed the variable its very weird but it worked. Commented Jan 6, 2023 at 19:39
0

Thanks for your response but the problem was the name of the variable I changed it and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.