Get post slug and match with menu item slug to change css
WordPress already has current-menu-item class. Following CSS can be applied. .current-menu-item{ background-color:#4ba668; color: white; display:block; } Thanks to bosco for his comment.
WordPress already has current-menu-item class. Following CSS can be applied. .current-menu-item{ background-color:#4ba668; color: white; display:block; } Thanks to bosco for his comment.
You need to target the the_title filter. In that filter we can manipulate the output string as we need. add_filter(‘the_title’, ‘bt_the_title’); function bt_the_title ($title) { if (current_user_can(‘administrator’)) { if (strlen($title) > 15) { $title=”<span class=”font18px”>” . $title . ‘</span>’; $title=”<span style=”font-size: 18px”>” . $title . ‘</span>’; } } return $title; } add the code in … Read more
Single Post function to display all single post images in a carousel
You can filter the output like bellow: <?php /** * @param $revision_date_author * @param $revision * @param $link * @return mixed */ function filter_wp_post_revision_title_expanded( $revision_date_author, $revision, $link ) { $revision = get_post( $revision ); if ( ! $revision ) { return $revision; } if ( ! in_array( $revision->post_type, array( ‘post’, ‘page’, ‘revision’ ), true ) … Read more
My website is showing today’s date instead of published date since db migration to a new wordpress
How to show posts in grid style on search result page?
wordpress admin missing Posts button
How to work with posts and sub posts?
You don’t need to loop through the posts for this. Instead, just call the method get_posts() which will return an array of posts and then just count the number of posts in that array. $user_id = get_the_author_meta(‘ID’); $args = array( ‘author_name’ => $user_id, ‘category_name’ => ‘categoryname’, ); $wp_query = new WP_Query($args); $posts = $wp_query->get_posts(); $my_count … Read more
Well in the end I used custom taxonomy, and it’s also more simple to manage. I post as I did : //hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires add_action( ‘init’, ‘create_regions_nonhierarchical_taxonomy’, 0 ); function create_regions_nonhierarchical_taxonomy() { // Labels part for the GUI $labels = array( ‘name’ => _x( ‘Regions’, ‘Where are … Read more