I never found out what stopped the function from working with WP 3.8, but I found that this variant of it does work – and I have no idea why:
<?php
function list_posts_from_current_category() {
if(is_single()){
$tempArray = get_the_category($post->ID);
$FirstCatName = $tempArray[0]->slug;
$this_post = get_the_ID();
$PostsPerPage = 5;
query_posts(array('category_name' => $FirstCatName, 'post__not_in' => array($this_post), 'posts_per_page' => $PostsPerPage, 'orderby' => 'rand'));
while ( have_posts() ) : the_post();
$ThisPermalink = get_permalink();
$ThisTitle = get_the_title();
echo "https://wordpress.stackexchange.com/questions/126571/<a href="<a href="#">ThisPermalink</a>">'.$ThisTitle.'</a><br />';
endwhile;
wp_reset_query();
}
}
add_action('do_my_list', 'list_posts_from_current_category');
?>
Related Posts:
- Get rid of WordPress category, tag and author archives?
- How to add the category ID to admin page
- How to create a widgetized sidebar for every category dynamically?
- Only show category to certain user levels without plugin
- List Categories of the Parent Category of the Current Category
- exclude category from WordPress Form function
- wp_list_categories, Add class to all list items with children
- Remove “Parent” Selection When Adding/Editing Categories?
- Check is category parent or not from its ID
- How to show in search results posts with a particular tag in a particular category?
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- If category is in parent category?
- If in category to be inside of a function
- Rename Default Category (Uncategorized) Via a Function
- Check child/parent categories if exists
- Getting URL of archive (category) page
- How to show only one category in breadcrumb navigation
- Query posts from category based on a filter most favorited
- Add tag parameter to category.php
- Random Featured Image Based on Category
- add slug beside name in Admin Category Checklists
- Change div background acording to the selected category
- How to use wp_list_categories with plugin category?
- Redirect depending on category chosen
- How to add icon over specific thumb
- How to load several hierarchical categories from functions.php
- Change Default Content when Creating a Post based on Previous Category Choice
- How to add a custom thumbnail size for a specific category?
- create function to call category name and slug
- Different size video display for category page (smaller) & detail page (larger)
- Code to display category-specific single.php is overriding normal single.php, too
- Loop Through Categories in Custom Field
- Show only one category in main query, issues on tag page
- Show parent-child relationship for categories in the wordpress admin
- Change Gutenberg category checkboxes to radios
- Checklist of selected categories
- Multisite – Protect categories from deletion?
- Why is per_page not working with categories in WP API?
- ajax category filter
- In the tag archive – display count of posts for each category they belong to
- Custom color for each category name
- Show posts of one category only with Custom Taxonomy on single.php
- Wrap a chosen category name with div
- Hide uncategorized products from the shop page
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Category tree is flattened inside admin upon saving
- Attach parent category template to all subcategories
- Get woocommerce catogry
- exclude a category from a search on a specific page
- Get last post date yesterday from each categories not work & double result post
- .htaccess too many redirects based on category slug
- Possible to display shortcode based on the category?
- Multiple categories PROBLEM and Duplicating main categories
- Exclude category from fucntion
- Get Unique Categories – Group By?
- How to redefine the sorting of product categories by menu_order?
- Filter Categories in meta box for CPTs
- Site search needs to find posts for category topic AND Tag or keyword thats not in the post
- Restrict author to create subcategory in a selected category
- categories on attachment page
- A single category with a specific permalink structure differing from the standard set for the rest of the site
- List only child categories within posts
- Admin comments and user restrictions
- category url structure
- How to restrict user to choose 1 category for a post
- Different Output for “Every Other” Foreach Statement?
- Post not populating for custom post type based on category selection
- Display list categories from CTP
- Latest updated categories list query, exclude one from displaying
- Shows only one Category in home page
- Get categories list with category name in custom WP_List_Table class
- Getting parent category hierarchy as objects from category template
- Setting selected term_id with wp_dropdown_categories?
- how can i hide category?
- Assign a list of categories with a parent category
- Custom post type archive category page results in 404
- How do I remove pagination from just some Categories?
- Using custom structure prefix showing 404 for sub-categories
- Showing the category hierarchy as clicked in WordPress, with image and desc
- Exclude a category and post_type from wp_query
- WordPress category title not update in navigation menu
- Deleted categories still listed until additional page refresh
- Limit post top level categories to one
- Alpha list no longer works it multiple names
- Display Some text in some specific category not all category
- Why use hierarchical taxonomies instead of many custom taxonomies?
- Breadcrumbs and Categories
- Jetpack Mobile Theme: when on smartphone on categories the theme suddenly changes to jetpack mobile theme even though it’s deactivated
- How To Get WordPress Categories Last Update Date?
- altering theme – content generated by PAGES not PORTFOLIO
- Bringing Ajax Loading Feature on Category Pages
- Need help with category page customization meeting certain condition
- How can i call from custom fields to the category editor?
- How do i add custom post types to this query?
- Dynamically Adding Category Specific Content To Specific Category & Subcategory Pages
- Structure with category setting
- chose category in plugin
- Do not show all post from all categories, just show posts from category in current loop
- How to prevent page re-sizing for mobile browsers [closed]
- how do I exclude a category foreach