How to get posts by multiple post slugs? [duplicate]
Try to put your post slugs in an array for the post_name__in parameter: ‘post_name__in’ => [ ‘berlin’, ‘frankfurt’, ‘munich’, ‘augsburg’ ],
Try to put your post slugs in an array for the post_name__in parameter: ‘post_name__in’ => [ ‘berlin’, ‘frankfurt’, ‘munich’, ‘augsburg’ ],
Use Ajax API provided by WordPress. In first time, fix your Ajax request : <script> $(“.post-link”).click(function(){ var post_id = $(this).attr(“rel”); //this is the post id $(“#post-container”).html(“content loading”); $.ajax({ url: myapiurl.ajax_url, type: ‘post|get|put’, data: { action: ‘my_php_function_name’, post_id: post_id }, success: function(data) { // What I have to do… }, fail: { // What I have … Read more
Speed factor of any function that deals with content such as wp_insert_post() or wp_delete_post() highly depends on the situation and the content that it’s dealing with. Let’s make a simple example. You have a post, that contains featured image, dozen of tags, categories, a thousand custom fields, assigned taxonomies, and a hundred more. When you … Read more
You can, but you shouldn’t. RSS feeds are built in XML. Not in HTML. Links in XML don’t have meaning because they’re HTML elements. However, because XML can be read by most HTML parsers (i.e. web browsers), you can easily mistake an XML document for an HTML one (the prevalence of XHTML helps to blur … Read more
You’re doing something that is affecting the value of the main $post variable in an incorrect manner. The WordPress template consists of one main Loop. That Loop, on a single post page, shows the one and only Post (or Page). When the comments form runs, it expects the last post from the Loop to be … Read more
In the following, ’10’ is the priority that my_func gets called and ‘2’ is the number of arguments that my_func accepts. The latter is important, since the add_filter function defines the default as 1, but the wp_insert_post_data filter hook sends two arguments. If you don’t set this as 2 you won’t get the second argument. … Read more
You need to use before_delete_post action. As its already very late when delete_post action is run. WordPress un-attach all the attachments before running delete_post action. So when you run get_posts in your delete_attachment function there are no attachments found. So you need to hook your function to before_delete_post. add_action(‘before_delete_post’,’abc_delete_attachment’);
The apply_filters() function lets plugins and themes override the value. So yes, you could manually set sslverify to false. The code snippet you included will set it to false in the absence of any filter. Let’s say I have a plugin that wants to force it to true. I would add this: add_filter( ‘https_local_ssl_verify’, ‘__return_true’ … Read more
The Codex page for is_single should be updated, what you’re seeing is correct behavior. According to the main Conditional Tags Codex page: is_single() When any single Post (or attachment, or custom Post Type) page is being displayed. (False for Pages) You can exclude attachments by also checking ! is_attachment(). Also, you may want to move … Read more
The 404.php template file is used for 404 errors: i.e. no posts found. Since there are no posts, there is no $post object. With no $post object, functions such as the_ID() are not available, and will return the error you’re observing. The fix: replace all instances of $post-derived data with static data. e.g. replace this: … Read more