get posts – Weird query with get_posts and WP_Query

Attempting to make a search in a custom post type “comunicados” inside a shortcode in a custom plugin I send this to get_posts()

Array
(
    (posts_per_page) => -1
    (post_type) => comunicados
    (post_status) => publish
    (orderby) => title
    (order) => DESC
    (s) => co
)

This returns all the content (pages, posts, other custom post types) but “comunicados”

I changed to WP_Query with the same result.

If I print_r the WP_Query I see this:

WP_Query Object
(
    (query) => Array
        (
            (posts_per_page) => -1
            (post_type) => comunicados
            (post_status) => publish
            (orderby) => title
            (order) => DESC
            (s) => co
        )

    (query_vars) => Array
        (
            (posts_per_page) => -1
            (post_type) => Array
                (
                    (0) => post
                    (1) => page
                    (2) => evento
                    (3) => informes
                    (4) => publicaciones
                    (5) => noticias
                )

            (post_status) => publish
            (orderby) => title
            (order) => DESC
            (s) => co
...
...
...

Note the post_type in query and in query_vars. Is not supossed to be the same?
Also I see this:

(request) => SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND (((wp_posts.post_title LIKE '{48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}co{48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}') OR (wp_posts.post_excerpt LIKE '{48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}co{48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}') OR (wp_posts.post_content LIKE '{48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}co{48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}')))  AND wp_posts.post_type IN ('post', 'page', 'evento', 'informes', 'publicaciones', 'noticias') AND ((wp_posts.post_status = 'publish'))  ORDER BY wp_posts.post_title DESC

It’s not using my post_type and also these weird strings {48ae2fbb00693ccb2a14823f0ece41e120c73baf24f9e905961bdb4a319d675d}

I’m not sure how to make this work

Why does my posts in custom post type becomes hidden when making the custom post type polylang ready

I have a custom post type (e.g. Books) that I have 4 Published posts. It shows up just fine in the website.
I installed Polylang to be able to translate those posts in different language.
To enable translation for my CPT, I went to Language > Settings and enabled translation by ticking the checkbox for the Books CPT.

Now I do see that there are 4 Published posts in the Books CPT but it seems they are “hidden”. The posts also aren’t being pulled in the website.

It seems I have to create new posts again.

How do I fix the issue?

I can provide screenshots if needed.

I will design creative social media posts for $1

I will design creative social media posts

Looking for someone to design creative posts for your social media, you are at the right place!

What I do?

I have more than 4 years’ experience in this field which makes me quick to understand buyers’ demands/needs. I have previously managed business accounts and designed posts for many clients.

What services I provide?

I will design creative posts that will help you with the branding of your product or business with eye-catching and creative social media posts.

Visit My Portfolio

https://bit.ly/2DzxZwK

I will take your ideas and my creativity and create splendid designs, with :

Original social media posts/images design

Color correction

Custom illustrations

Infographics,

Effects

High-quality Designs

PNG/JPEG/PSD/AI files.

Professional work in little time (saves your quality time).

Design for Facebook, Instagram, Instagram stories, Twitter, Pinterest, Facebook ads, Banners, LinkedIn or any platform you want

Please make sure you’ve all the content ( text per post) ready for posts before placing an order.

If your requirements are different, Kindly contact me to make changes.

Regards,

ashik

.(tagsToTranslate)socialpostdesign(t)socialmediabanne(t)social(t)media(t)pos(t)ad

javascript – Correct way to delete posts and unlink images using NODE JS

I have the following tables in MySQL:

create table PostSchema
(id int not null primary key auto_increment,
categories int not null,
title varchar(50),
status varchar(20),
comments bool,
body varchar(255),
filename varchar(255),
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP);

create table commentSchema (
id int not null primary key auto_increment,
userID int,
message varchar(255),
image varchar(255),
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
postID int);

Currently..

When a post is created it saves an image in '/uploads' and filename is referenced in PostSchema.

Also, when a comment is created with an image it is also saved in '/uploads' and filename is referenced in commentSchema.

My Idea

I have a router set up to delete the records from PostSchema and any comments are relevant in that PostSchema. On top of that delete any images referenced for both tables.

I have a working code, just want to hear some reviews if there is anywhere I can improve 🙂

Current working code:

router.delete('/:id', (req, response)=>{
  // Execute query for deleting the post

    // Get filename from database
    db.query("SELECT filename FROM PostSchema WHERE id = ?", req.params.id,(err,fileResult)=>{
      // If error
      if(err){
        return res.status(500).end(err.message);
      }
      // If not an error continue...
      else{

        try {

          // Unlink comments images
          db.query("select image from commentschema where postID = ?", req.params.id, (cErr, cRes)=>{
            if(cErr){
              return res.status(500).end(err.message);
            }
            else{
              if(fs.existsSync(uploadDir + cRes(0).image)){
                fs.unlink(uploadDir + cRes(0).image, (commentFile) => {
                  if (commentFile) throw err;
                });
              }
            }
          });
          
          // Unlink PostSchema images
          fs.unlink(uploadDir + fileResult(0).filename, (errs)=>{
            // Delete PostSchema + Delete comments
            db.query("delete t1, t2 from postschema t1 join commentschema t2 on t1.id = t2.postid where t1.id = ?;", req.params.id,(errors, results)=>{
              if(errors){
                console.log(errors);
              }
              else{
                db.query("delete from postschema where id = ?", req.params.id, (er, res)=>{
                  if(errors){
                    console.log(errors);
                  }
                  else{
                    // Redirect to all posts page
                    req.flash('success_message', 'Post was succesfully deleted');
                    response.redirect(303, '/admin/posts');
                  }
                });
              }
            });
        });
      }
      catch (e) {
        return res.status(500).end(e.message);
      }
    }
  });
});

I will design new social media posts and contents for your business. for $1

I will design new social media posts and contents for your business.

ATTRACTIVE SOCIAL MEDIA POSTS AND CONTENTS.
If you want to boost your business you are required some attractive and unique media posts, so i can take you at high ranking. Just give me a chance because i can provide 100 percent satisfactory work.
Thanks!

.

homepage – Limit posts only on home page – ideally in functions.php

I’d like to restrict the number of posts that show on my home page to 3, but have all the other archive, category, pagination pages, etc. at whatever number I set in the “reading” settings in the WordPress dashboard.

Is there a nice way to do this in functions.php?

I tried the following, which does limit the posts on the home page to 3, but it also creates pagination links to pages with 3 posts each.

    add_action( 'pre_get_posts',  'change_posts_number_home_page'  );
function change_posts_number_home_page( $query ) {

if ($query->is_home() && $query->is_main_query() ) {
        $query->set( 'posts_per_page', 3 );

return $query;
}

Thanks in advance!

Create 7 social media post with images for $20

Create 7 social media post with images

Looking for someone to design creative posts for your social media. You are at the right place.

Social media posts with relevant content are the key to generate sales and raise genuine interest for your brand. Chances are, you don’t have time to write these and that’s where I can help you with my expertise. I am experienced in creating social media content for most major platforms and creativity is what excites me the most.

Writing is my passion. I can brainstorm ideas and create posts according to your specific requirement. I will write 7 short & lucrative social media posts and find relevant images for each post. The content of each post will be unique for your business to generate more audience. You can use these posts for your Facebook, LinkedIn & Twitter accounts.

For best work quality I need clear instructions for the order so that I can match up to your expectations. The more precise you are the better the posts will be to fit your needs.

I would love to hear from you. Feel free to contact me if you have any questions regarding my service. I would be happy to work for you.

.