url rewriting – 404 error- issues with pages after adding custom rules for posts

I am trying to create a custom translation for my website.

Quick Story:

I am facing “404 error-Page Not Found’ issues with pages after adding custom rules in functions.php

$newrules('^th/(.*)$') = 'index.php?name=$matches(1)';
$newrules('^se/(.*)$') = 'index.php?name=$matches(1)';

with the above code, posts with /th/ slug are working perfectly fine but my pages with /th/page-name-1 … throwing 404 error-Page Not Found

So here is the complete story:

First I created a parent page “Home Thai” https://mywebsite.com/th/
and under that parent page “Home Thai”, I added the rest of the Thai language pages, so results coming like this

mywebsite.com/th/page-name-1
mywebsite.com/th/page-name-2
mywebsite.com/th/page-name-3

Now I want to set up Thai Post URL with slug (/th), and to make this, I added the below new rules in functions.php

$newrules('^th/(.*)$') = 'index.php?name=$matches(1)';
$newrules('^se/(.*)$') = 'index.php?name=$matches(1)';

with the above code, posts are working perfectly with language slug (/th/, /se/). bit my pages with /th/page-name-1 … throwing 404 error-Page Not Found

Script:

//Create a function to register a new language translation taxonomy
add_action('init','nk_add_translation_taxonomy');

function nk_add_translation_taxonomy(){
   
    global $post;
    //set the name of the taxonomy
    $taxonomy = 'nk-post-translation';
    //set the types for the taxonomy
    $object_type = array('post');

    //populate our array of names for our taxonomy
    $labels = array(
        'name'               => 'Post Translation',
        'singular_name'      => 'Post Translation',
        'search_items'       => 'Search Translation',
        'all_items'          => 'All Translation',
        'parent_item'        => 'Parent Translation',
        'parent_item_colon'  => 'Parent Translation:',
        'update_item'        => 'Update Translation',
        'edit_item'          => 'Edit Translation',
        'add_new_item'       => 'Add New Translation', 
        'new_item_name'      => 'New Translation',
        'menu_name'          => 'Post Translation',
              
    );
    
    //define arguments to be used 
    $args = array(
        'labels'            => $labels,
        'hierarchical'      => true,
        'show_ui'           => true,
        'how_in_nav_menus'  => true,
        'public'            => false,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array('slug' => 'post-translation')
    );
    
    //call the register_taxonomy function
    register_taxonomy($taxonomy, $object_type, $args); 
}

add_filter( 'post_link', 'custom_permalink', 10, 3 ); 
add_filter( 'rewrite_rules_array','customLangaugeSlugRules');
add_filter( 'init','flushRules'); 

// creating of post permalink from taxnonmy slug
function custom_permalink( $permalink, $post, $leavename ) {
    $category = get_the_terms($post->ID,"nk-post-translation"); 

    if (  !empty($category) && $category(0)->slug == "th" )
    {
      $permalink = trailingslashit( home_url('th/' . $post->post_name ) );
    }
    elseif (  !empty($category) && $category(0)->slug == "se" )
    {
      $permalink = trailingslashit( home_url('se/' . $post->post_name ) );
    }
    else
    {
      $permalink = trailingslashit( home_url( $post->post_name ) ); 
    }
    return $permalink;
}

// using because of its flush the exixsting rules of taxnonmy slug rules
function flushRules(){
  global $wp_rewrite;
  $wp_rewrite->flush_rules();
}

// inserting new rules of taxnonmy slug
function customLangaugeSlugRules($rules)
{
    $newrules = array();

    $newrules('^se/(.*)$') = 'index.php?name=$matches(1)';
    $newrules('^th/(.*)$') = 'index.php?name=$matches(1)';

    return $newrules + $rules;
}

I Will be Perfect Data Entry Works For Your Business for $5

I Will be Perfect Data Entry Works For Your Business

Hi,well come to my gig,
I am here to assist you as a virtual assistant with any kind of data entry, web research.data mining,typing,Microsoft word or excel work with the best services and professional skills, i am available 24*7 online , i am eagerly looking forward to help you.
the services i provide:

data entry{company,website,contact,person,email,phone number and address/location}

  1. data mining,
  2. data scraping
  3. web research
  4. led generation
  5. email list building
  6. LinkedIn marketing
  7. Business info
  8. data conversion
  9. PDF to word
  10. PDF to excel
  11. email management
  12. typing
  13. copy paste
  14. competitor data analysis
  15. keyword research
  16. company business information research
  17. virtual assistant

service is specialist

please send me a message if you have any question and if you have any project to discuss with me,

best regards

Varese.

.

SUPPORT – Why posts are removing? | Proxies-free

Hi, I wrote post about Revo Uninstaller today. Why did you remove it? If something was missing or wrong, I could edit post and improve it. Why did you remove it completely? Maybe you could make it draft so I could edit and repost it but now, I have to write it again. At least you could send the post which you remove with pm so we won’t write our posts from beginning. And also if I write it again, will you remove it? Should I write or not?

SEO services – 100 PBN Homepage and Permanent Posts for Ranking Towards Google Page 1 for $45

Q: Do I really need PBN Back-links?

A: Good question! You need this to increase your sales, website metric and website traffic.

Q: Will my site get penalized for using this service

A: NO, your site will not be penalized.

Q: How many URL can you use in one order?

A: I will use a single URL with 5 Keywords.

Q: Do you guarantee the SERP improvement?

A: Of course, 100% guarantee for SERP fast improvement.

Q: Do you provide reports?

A: Yes, I will provide a complete and detailed report of the work.

Q: Are your sites indexed on Google?

A: Yes, all our sites are well-indexed on Google.

Q: How long will the post stay on the website ?

A: Your post will remain on the site’s page for 1-3 Month and then will roll off to the inner pages PERMANENTLY.

Q: What is the average turnaround time?

A: Turnaround time is 1 to 2 working days to see the result.

Q What is the refund policy?

A: We will fully refund the money if we fail to deliver what we claimed.

Q: Are these links permanent?

A: Yes, all links are permanent.

Q: Do you accept gambling, illegal, or drugs related websites?

A: Yes accepting.

Q: Do you accept foreign keywords?

A: Yes we do, but the comment will still be in English.

.

design – How to segregate blog posts into seen and unseen?

Imagine an app like Instagram/Reddit with a feed of posts.

Problem: We want to show users posts they have not seen before.

When the user first opens the app, we retrieve 30 latest posts from the backend and show them to the user.

The user sees 10 posts and leaves the app.

At this point, the user has seen post with id 30 - 21 and not seen post with id 20 - 1

When the user comes back the next day, the database in total has 40 posts.

This time, when the API retrieves the latest posts, it also fetches 10 of the same old posts that the user has already seen.

We want to be able to skip the posts that the user has already seen.

Probable solution:

Divide the entire feed into SEEN and UNSEEN ranges. These ranges can be identified by their start and end markers, AKA post IDs.

For example, when the user leaves the app for the first time, we store it as a range. -> (30,20)

This range identifies posts already seen by the user.

Next time when the user opens the app, we send these ranges to the API, and then the API filters posts such as posts on either side of this range are returned. Posts between this range are not.

Sample SQL:

SELECT * from post where Id > 30 OR Id < 20

If we have multiple ranges, for example (50, 40) and (30, 20) the SQL becomes:

SELECT * from post where (Id > 50) OR (Id < 40 AND Id > 30) OR (Id < 20)

Essentially, we are dividing the feed into black/white or seen/unseen markers.

However, while this seems plausible, there are cases when the ranges become overlapping. For example, when the user opens the app with 50 posts, he/she might actually go down to post id = 7 and then leave the app. The correct range for this user should now only be (50, 7). How would these be efficiently merged then?

Are there any other/better solutions to this problem?

theming – Can I add pagination to individual blog posts in my twig file?

I have a views page which has all the blog articles, and you can click on a link to bring you to a single blog page.

On that single blog page I want to be able to add buttons for Previous and Next post. Something like

<a class="white-btn" href="{{ previous.href }}">Previous Article</a>
 <a class="white-btn" href="{{ next.href }}">Next Article</a>

Is this possible?

I will write and publish 100 guest posts and 10 profile creation backlink on high DA sites for $50

I will write and publish 100 guest posts and 10 profile creation backlink on high DA sites


Remember only relevant and high traffic websites can help your website to rank on Google’s 1st page. I will write 500+ words each and publish on HQ carefully curated 100 blogs, All are DA90-40 TF 20+ Best quality Backlinks which is effective for improving your Domain Authority and Google ranking.

I will write premium quality articles as well, and the post is Permanent,Dofollow, Nofollow mex! I will also give you 10 social profile backlinks that will rank your website.

Why Choose Our Service?

  • Unique Article
  • Real Websites
  • Permanent Backlink
  • Boost Ranking

Service Features:

  • I will provide all backlinks report in a excel.
  • Contextual/Noncontextual Backlinks.
  • All links will be publicly viewable & permanent.
  • Dofollow/Nofollow Mixed links.
  • I will use only English Websites/Articles.
  • 100% Google friendly process.
  • All Links will be created 100% manually.
  • Right Time Delivery.

Accept all Niches: gambling, casino and pharmacy

.

custom field – How to display Common posts from specific Tag & Category with Shortcode

How to display posts that are common in Category A and Tag A, and I want to display posts by shortcode so that the Shortcode can be used on multiple locations with different category Ids and Tags.

I found the below code by google but don’t know how to implement it in functions.php and not sure how to use it in the shortcode. I want to display Post Title, And Some Custom Field Value (For Example – Value A, Value B) in a table structure.

        $args = array(
        'category__and' => 'category', //must use category id for this field
        'tag__in' => 'post_tag', //must use tag id for this field
        'posts_per_page' => -1); //get all posts
        $posts = get_posts($args);
        foreach ($posts as $post) :
       //do stuff 
        endforeach;```

posts – How to prevent WordPress from purging inline CSS?

Given the following excerpt of a post:

you're clear to just write <code style="white-space: nowrap; background-color: cyan;">with epoll() as E: …</code> and everything will be OK. The epoll descriptor will get properly closed, detached, etc.

The background-color directive (which I don’t want ultimately; it’s just a “canary” or “test”) remains in the post and is used.

However, the page does not include the white-space directive, even when the raw HTML is fetched, unadulterated by JavaScript. And, when I edit the post later, I see that the directive has been removed.

Is there a way to add CSS directives to a whitelist, or (better yet) disable this whitelist/blacklist for posts? I don’t see a need to “sanitize” the code in this case; site authors are allowed more creative control than


For anyone else stumbling across this question: the workaround I’m using for now is a spot of custom CSS

p>code.language-python {
    white-space: nowrap;
    /* https://wordpress.stackexchange.com/q/380863/52811 */
}