Articles of posts

Easy reading or transfer of data from posts?

Plugin usually transfer data using code like [espro-slider id=21] , is there a short way to read it or do they use regex to read it. If not is there a short way to define variable in post and use it directly in back-end. I am trying to read information from post and use it […]

Insertion of a non-english string to database

How can i insert a non-english string (like persian) to a tabale in WordPress database? When i insert the persian string, It shows with “??????” character in the table? This is the code: -Creating table: function fjn_add_polls_table_to_db(){ global $wpdb; $polls_table = $wpdb->prefix. ‘polls’; if( $wpdb->get_var( “SHOW TABLES LIKE ‘{$polls_table}'” ) != $polls_table ){ $query = […]

Unable to differentiate between two categories under custom post type on single.php

I have created A custom post type as mentioned in my older question When I try to use get_the_category() function to retrieve the category of the post(if it is symphony or noir). It returns “Array”. How can I keep the posts under the two categories separate which do not interfere in the pagination of one […]

How to convert query sql to shortcode in wordpress?

I want to make a shortcode like this [myshorcode:2:drinks], and query-wrangler I have managed to get the following query that shows me 2 products of a certain taxonomy PHP WP_Query: $query = array ( ‘paged’ => 1, ‘posts_per_page’ => ‘2’, ‘offset’ => 0, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 0, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, […]

How can you display all sibling categories to a post?

I would like to achieve a list of sibling categories to the deepest level category (4 or 5 levels deep) of my posts, for example: Post about South Sudan (breadcrumbs = World, Africa, East Africa, South Sudan) Display all subcategories to South Sudan. Then I would like to be able to do the same thing, […]

List all posts, pages and custom post types in admin

I want to create a drop down in my WordPress admin containing all posts, pages and custom post types. The return value should be a link to that page or an ID of the page. Is there something build in for this, or is there an easy way to do it? Thanks in forward.

Add simple field column to the posts screen

I know that manage_posts_columns is the hook for managing the column in post screen. I can add a column with following code, // add new column hook add_filter(‘manage_posts_columns’, ‘add_new_column_in_posts’); function add_new_column_in_posts($columns) { $columns[‘premium’] = ‘Premium’; return $columns; } My question is, how can I feed the simple_field value for that column?

$wpdb returns duplicate posts

I have created a shortcode which shows the posts which were created after the user last logged in. The shortcode is working perfectly fine, but I am not sure why but I am getting 7 duplicate posts. So like for test I created a post named as “Sample Article”, and when I echo out the […]

How to get all inline images in post content?

This question already has an answer here: Extract image src from a post and send it to an external form 2 answers

get current post id inside hook

I have created this hook to send notification only when new post is published. In notification I am sending link and title of post which is newly created. For that, I need current post id inside function. How can I get it ? add_action( ‘new_to_publish’, ‘send_notification’, 1 ); function send_notification(){ $post_data[‘ID’] = the_ID(); $post_id = […]