This is a new query loop that I use that shows the latest ten post titles/permalinks in the category mycategoryname and strips the first 15 characters from all of the titles.
<?php $my_query = new WP_Query('category_name=mycategoryname&showposts=10'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="https://wordpress.stackexchange.com/questions/14120/<?php the_permalink() ?>" title="Permanent Link to: <?php the_title_attribute(); ?>">
<?php $mytitle = get_the_title(); $mytitle = substr($mytitle,15); echo $mytitle; ?></a>
<?php endwhile; ?>
If you need to select which posts to strip either 8 or 10 characters, you’d have to select them by some sort of criterea and alternate that character number.
Related Posts:
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- WordPress Warning: preg_replace(): JIT compilation failed: no more memory
- Append code into wp-config.php
- Use Filename for Alt and Title Tags
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- Trying to use Ternary operators with WP Conditionals
- Filter link to existing content suggestion
- How to strip non-alphanumeric characters, convert spaces to dashes, uppercase to lowercase in this context
- How to return multiples lines in a shortcode?
- wp_enqueue_style with style.php and WordPress functions
- Generate an array of parent/child page IDs, based on parent page name
- fallback image for featured image
- Add attribute / custom attribute to product in woocommerce
- Access/update database with jQuery
- How to create another version of my site based on the same database
- How to get bool with `get_option()` when already registered setting with type `boolean`
- Why is this Ajax not working?
- Stumped on migration
- Count the number of times the search form template gets included on a page
- Displaying theme options in css
- PHP code inside shortcodes
- How to show part of the_content?
- PHP help get_template_directory + PHP include
- WordPress plugin/code to hide all things related of a user from the public
- Querying wpdb using PHP
- Reload part of checkout on changed shipping method
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- how to combine wordpress htaccess on my root domain + php on subfolder
- Input data from email form not going to JSON file
- edit search.php to include subdomain posts
- Remove echo from shortcode
- Copyright info change – Corporate Plus Theme PHP [closed]
- Inject class in body when particular page template is used
- Should `wp_login` be used since it’s deprecated?
- Category title output before opening title tag
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- How to use a custom hook
- Hide HTML element (by class or ID) with PHP
- Jquery window.send_to_editor function
- PHP: Showing currency sign if input is a number
- How to say if meta_value is greater than 0 in an array?
- Adding a tag_ID column into Categories inside the admin dashboard?
- Verify if a category is the child of another category
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Redirection after submitting duplicate comment
- How to get category name or ID by post?
- ACF Repeater Pagination stopped working since upgrade to php7.2
- Using featured image of blog archive page
- Best Way to Change a String in a WordPress Post
- Highlight the links without using dropdown
- Automatically Add Page Links to Nav Menu
- blank white page when post/update/change option etc
- How to wrap every 3 posts in a div (and close the last div too) [closed]
- Dividing the loop to style post differently
- add button to specific post
- Why, when moving a WordPress multisite network, have my theme customisations stopped working?
- Where should I copy a PHP file from wp-includes to, in order to override it in my child theme?
- How to edit wordpress pages through cpanel? [closed]
- Is it possible to restrict files from your wordpress uploads (not logged-in users or guest)?
- Adding attribute to the post.php form tag in wp-admin
- include content within conditional statement?
- How to get movies by date
- How to change the author box selection on a post to a custom taxonomy
- Is there way to toggle the publish date display?
- How to send a php var to jQuery Ajax call with two different file
- not outputting medium size image URL
- Help me I cannot link my font-awesome to my WordPress Theme. I have my font-awesome folder already in my project
- Echo short code syntax
- WordPress recent post
- Download Featured Image Link in Post Shortcode
- Show subcategory name selected in specific category woocoommerce
- Posts Per Page with a button to add more Posts
- Cannot fetch posts with certain ‘product_cat’. WP_Query is empty
- Add custom attribute to product’s HTML to woocommerce cart page
- Change WooCommerce template for PDF – access to custom field
- Detect what link user clicks and Redirect to a specific page for logged in users only
- Decoding an array in PHP (from the Shopify API) [closed]
- PHP Session Variable to WordPress Error
- Advanced WordPress SQL Query
- Run code before WordPress loads and insert data into WP if need be
- Editing existing pre-created menus in PHP
- Create a hierarchical loop at predefined markup requirements
- Custom Meta Boxes and Fields Multicheck Issue
- nested divs, classes for a grid in loop [duplicate]
- Themes with variable width or single columns? I want to display source code
- Category List in Theme Options Page
- Showing all post from all post type in admin backstage
- Or operators in PHP [closed]
- how to iterate through xml data?
- Adding slides to an existing carousel manually
- Shortcode to include PHP file, pass various parameters to include?
- Why can’t I include echo inside a variable? [closed]
- What does this if-statement do?: if($pages=’ ‘) {}
- Really slow WordPress site [closed]
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- How to increase excerpt length in wordpress? [duplicate]
- Are WordPress & PHP objectively and based on evidence going to die because the future is made of frontend rendering instead of server side rendering? [closed]
- Not able to see the error [closed]
- Pull latest Youtube Video from json url and make new post