New answers tagged

1

I am not sure why you prefer the longer method over wp_get_archives(). I recommend letting Wordpress do the work for you. It is more efficient, and easier to read. However ... since you presented a particular preference: It would appear that you are using an array for post_type, when none is required. Try modifying your WP_Query args to: $terms_year = ...


0

function excerpt_readmore($more) { return '... <a href="'. get_permalink($post->ID) . '" class="readmore">' . 'Read More' . '</a>'; } add_filter('excerpt_more', 'excerpt_readmore'); Please add above code into functions.php


0

Have you tried wp_trash_post? This seems like the perfect fit for your purpose. It will only permanently delete posts if you have your trash disabled, or added define('EMPTY_TRASH_DAYS', 0); to your wp-config.php file.


0

Why don't you rather try to connect 2 wordpress to the same database ? On website B you can heavily restrain the capabilities of users. This way it will be only a sort of mirror. Another path could be to use the rest API from website A to fuel the content from website B. Have a look on api documentation: https://developer.wordpress.org/rest-api/


1

Publish date - The date on which a post or page is created/Published Modified_date - The date of the post with recent modification If you are presenting only one "News date", you can use modified_date because news are always updating. The the users can easily understand.


0

Changing any URLs will have an effect on your SEO. So, if you want zero effect on SEO, you cannot also change URLs from example.com/post to example.com/blog/post. You'll want to look at how well-established your site is - if you have hundreds or thousands of posts that are ranking well, you likely should not change URLs at all. However, if you have a newer ...


0

You can enable it for screen options above if still not works you can install the classic editor plugin to go back to old wordpress admin editor


0

As per your question, I am understanding as you want to display layout as Odd & Even Style. So I have fixed your code. Below fixed code you can try it. <div class="main_blog_content"> <?php $i = 1; $arr = array('posts_per_page' => 4); $arrg_query = new WP_Query($arr); if($arrg_query->have_posts() ) : while($arrg_query-&...


0

You can use User Role Editor plugin and edit or add new user rule. User Role Editor WordPress plugin allows you to change user roles and capabilities easy. Just turn on check boxes of capabilities you wish to add to the selected role and click “Update” button to save your changes.


0

The default Feature image size in wordpress is 768px width (is a hiden image size that use to be use by themes) The limitations of the image size are your theme (you must not have a different image size as the frame of your image in the post). But if you are a developer and you would like to modify the image size. Those are the recomendations in articles ...


0

single.php will only display a single post on the other hand index.php is the default template that displays everything including posts, post, page, categories, and tags only if specific template file is not present.


0

I would recommend this plugin to add titles and content list with links


0

You could try redirecting the old url to your homepage (or another appropriate page on your site). If you don't know how to setup redirects yourself, you can use a plugin like https://redirection.me/ Also, check to see if the page is still indexed in Google by searching "site:yourdomain.com/yourpage"


0

Try to flush the permalinks (press save on the permalinks page) Check settings>>reading to see if you have another page used for your "posts page"


0

Try this. Paste your code in the "text editor" and UPDATE it without clicking the "visual editor". See the preview of the post.


0

Please verify that in Settings -> reading the number of posts -> Blog pages show at most the value is greater than 1.


0

To display post id 149443, inside the first while() loop just use if ( get_the_ID() == 149433 ) and for the others use if ( get_the_ID() != 149433 ). The trick is to rewind the loop between the 2 uses so that you can use it again, so after the first loop use $special_reports->rewind_posts();


-1

if((get_the_category_list() !== 'Uncategorized')){ the_category(); }


1

WordPress doesn't provide any built-in endpoint or API to handle incoming mail and parse it into a action. So I see 3 possible options: Use a existing mail parser for WordPress and figure out a way to run a action Configure email inbox on your server and pipe incoming emails to a script to be able to parse it using a PHP parser like mailparse and then ...


0

To change the color of password protected post titles in the admin In your theme or child theme, enqueue a stylesheet to load in the admin, then add some simple CSS to change the color using the class that is given to password protected posts. In your theme's functions.php... function wpse_admin_styles(){ wp_enqueue_style( 'admin_css', ...


1

I just find out what I was missing at the top, after get_header();. <?php if (have_posts()) : while (have_posts()) : the_post(); ?> and at the bottom, just before get_footer(); <?php endwhile; ?> <?php endif; ?> So I just figured out that I was not loading archive properly, so I don't get all his information.


0

Found this snippet after more searching: //Force posts of custom type to be private //…but first make sure they are not 'trash' otherwise it is impossible to trash a post function force_type_private($post) { if (($post['post_type'] == 'post') { if ($post['post_status'] != 'trash') $post['post_status'] = 'private'; } return $post; } ...


0

In addition to @tobidude's great solution, a complete exemple: Create the functions function sortCategories($categories) { // Sorting the category usort($categories, "cmpCategories"); return $categories; } function cmpCategories($category_1,$category_2) { // Sort function foreach(get_categories(array("parent" => $category_1->cat_ID)) AS $...


0

Change $wpb_all_query->prev_post() to $wpb_all_query->the_post(). Class WP_Query does not have prev_post() method, it has the next_post() method, which takes the next post from the results (set up post member of WP_Query object), but it does not set the global variable. To reach for the data of the current post, you must use $wpb_all_query->post (...


0

I found the answer. Notices in the Block Editor would require JavaScript code. ( function( wp ) { wp.data.dispatch('core/notices').createNotice( 'error', // Can be one of: success, info, warning, error. 'Error Message.', // Text string to display. { isDismissible: true, // Whether the user can dismiss the notice. ...


0

Expanding on @Brian Fegter's answer Above you could use the below plugin to remove posts in bulk. It creates a WP admin page with a text area for ids of pages/posts to remove. <?php /* Plugin Name: Delete Posts By ID Description: Delete posts and pages by id Version: 0.1 Author: WPSE License: GPL2 */ add_action( 'admin_menu', 'deletePostsMenu' ); ...


0

The concept above is sound - but I was wondering is it the fact. So I looked at the ID column definition of the wp_post table in the database and it is marked as "AI" (meaning auto increment). This means the database is the implementation of the ID increment. I think this means it will always be bigger than the previous value (typically +1) however in ...


-1

The sticky posts was the problem, Thanks to @Michael answer, I have excluded the sticky_posts from the query 'ignore_sticky_posts' => 1


0

I'm not sure if it's possible to do this in a single query in Wordpress. You could potentially split it into two like below: <ul> <?php global $post; // Get posts by selected post ids $args = array( 'posts_per_page' => -1, 'post__in' => [12345,12543], 'orderby' => 'post__in' ); $myposts = get_posts($args); foreach ...


0

function wpse340250_term_count( WP_Term $term, $post_type) { $q_args = [ 'post_type' => $post_type, 'nopaging' => true, // no limit, pagination 'fields' => 'ids', // only return post id's instead of full WP_Post objects will speed up 'tax_query' => array( array( 'taxonomy' => $...


1

You can use the wp_link_pages_link filter like so: // Specify the text even if they're same as the default. This is for the filter below to work as intended. $prev_text = 'Previous Page'; $next_text = 'Next Page'; add_filter( 'wp_link_pages_link', function( $link ) use ( $prev_text, $next_text ){ if ( false !== strpos( $link, $prev_text ) ) { // It's a ...


Top 50 recent answers are included