Create custom page in WooCommerce

Create a new page in /wp-admin (in the left column: Pages -> Add New); create new custom page template after reading through this doc; put your code in there; go into the page you created in #1 and assign the page template to it (in the right column, Page Attributes box, the drop-down under ‘Template’ … Read more

Where can I find the code how wordpress parses a post?

The specific function you are referring to is wpautop, which adds paragraphs & HTML linebreaks to already intermixed HTML & plain text. wpautop is part of a family of content-processing functions hooked to the_content, a filter applied to the post content after pulling from the database just before outputting. Taking a look at wp-includes/default-filters.php, you … Read more

the_post_navigation seems to ignore same category filter

You mention a custom post type, are you also using a custom taxonomy? If so you need to specify this taxonomy in your function call: the_post_navigation(array( ‘prev_text’=>__(‘previous project: %title’), ‘next_text’=>__(‘next project: %title’), ‘in_same_term’ => true, ‘taxonomy’ => ‘wpse240053_custom_taxonomy_name’, )); By default the built-in category taxonomy for Posts is used. This requires WP4.4 or later.

What is the best / efficient way to get WordPress content by post id and why?

The methods you offer for comparison are pretty much the same, with minor API differences and whether the_content filters are applied. Within the loop get_the_content() should typically be used, which properly handles split into pages and so on. To retrieve raw content get_post_field() is generally suitable, but any further processing (such as the_content filters) heavily … Read more

Force “Submit to review” when a post is updated

It is possible to stop author to publish post, and force him to Submit For Preview. Just add this code to your functions.php and you are all done. <?php function take_away_publish_permissions() { $user = get_role(‘author’); $user->add_cap(‘publish_posts’,false); } add_action(‘init’, ‘take_away_publish_permissions’ ); ?> ** Updated Code ** This code shared here is for setting post status to … Read more

How to get year, month and hour in WordPress?

PHP Date Format in WordPress function: You’ll have to use the proper date format string (as used in PHP date function) in the WordPress get_the_date() function’s first parameter. For example, to get the Date & Time in the format like 2018-07-23 23:59 (i.e. YYYY-MM-DD HH:MM, where hour is in 24 hour format), you need CODE … Read more

How to get previous 10 days post from a specific date – WP Query

Yes, it is possible. You can pass full date as before and after params, so: $given_date_as_time = strtotime(‘2017-11-22 00:00:00’); $args = array( ‘post_type’ => ‘post’, ‘date_query’ => array( ‘before’ => date( ‘c’, $given_date_as_time ), ‘after’ => date(‘c’, strtotime( ‘- 10 days’, $given_date_as_time ) ), ), ); $query = new WP_Query( $args ); above query is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)