First off, ensure that the category is exactly the same name as the page ( slug and all ). Secondly, the parameters you’re passing to WP_Query
is incorrect.
category_name
expects a slug. For example,Page 1
would have a slug ofpage-1
.get_the_title()
pulls the current page title – so you’re passingPage 1
to a parameter that expects a slugpage-1
.
What you can do is sanitize_title( get_the_title() )
or preferably you could declare global $post
at the top of your document and pass instead $post->post_name
.
Related Posts:
- Custom HTML structure in wp_list_categories
- Can’t load WP function into external function
- Grab posts by multiple categories
- Populate editor with some content of a page with a page template
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Use .php file as page instead of wordpress page & template file?
- Use WordPress function in php file
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Show About and Contact Us page when they’re clicked in the top menu.
- Toolbar Hidden in a Virtual Page
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- How do I edit the terms output args or array data?
- When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php
- Category Page Displaying all Pages
- Create category after theme setup and modify the default one
- Create a custom theme-specific page, invisible in the admin-panel?
- Adding Media button to only pages
- Custom theme on multisite has issues with standard loop output
- Displaying theme options in css
- max_input_vars: how many am I using?
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- Category Thumbnail Display – How to display ONLY the main Category
- Where do posts get the sidebar from?
- Set WordPress Default Template
- Adding country tags automatically
- write custom woocommerce templates and forms
- Implement toggle switch for theme options in settings API
- Insert a button on a page with random number generation
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- get current product name in functions.php
- Using a variable in is_page(array())
- Trigger popup in a php if/else statement
- Anyway to output the registration form like the login form with wp_login_form()?
- How do I get current page ID in WordPress customizer file?
- Can’t get page content in WordPress
- Customizer: Output default value in Customizer CSS
- Way to querry data (tags) from a wordpress database?
- How to load a template-part based on a url wildcard?
- get post based on category chosen in drop down – The ajax method
- WordPress does not load page.php, return 404.php
- How to use transient in this code for related post?
- Global variable $post returning incorrect object
- How can I load a PHP page without using a Template?
- How can i upload images in an admin page?
- Where to edit the template that is generating the code for dynamic_sidebar left-sidebar in the Understrap theme? [closed]
- Multiple WordPress Menus that will only display all pages
- editing fonts of category links from the_category() funtion
- Creating a related post section based on similar categories
- Set the checkbox as checked by default at options page
- Swapping wp_dropdown_categories function with wp_category_checklist
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Add child pages of parent to navbar PHP
- How can I create a list of page titles from custom meta values?
- Load a page into a div with Ajax
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Best practice for migration friendly images in posts/pages?
- Theme Options Page – User Updates Logo
- Converting HTML Template to WordPress Theme
- Proper syntax or method for keeping url in modified isotope / category links
- How to use my style.css file outside of wordpress subdomain?
- Apply different Class for each element in a foreach()
- How to show part of the_content?
- Page Automatically Generated from Theme?
- Wp-login appears White Screen, Error: Cannot modify header information
- Filter Select results based on selection
- How to remove the cufon script from Dzonia Lite theme [closed]
- get_the_tags() not iterating through for/while loop, but will with foreach
- How to add a php custom page to WordPress
- Sort query_posts for Parent Pages to menue order or the count?
- How to hide all child pages with post_query?
- Hide categories that are not used in the post type
- What is an equivalent of single_cat_title for getting the slug of the category?
- Issue adding sub category programmatically
- How do I add custom bulk actions to multiple custom post types?
- Add_action not working in required file of functions.php
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- what is the best practice to add new field to an api route
- WP grandchild categories in nested ul li
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Can’t access variable outside for loop
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- add custom link to wordpress media gallery modal
- How to show single category archive
- Move category description below post list in blog
- Need Help Fixing My Iframes [closed]
- How to pick the default selected value in wordpress dropdown?
- Avoid parallax images hardcoding
- Improve page speed loading using CDN and async or defer attribute
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- populate form fields in a loop with ajax
- Error in custom php function doesn’t exist
- Customizer: active_callback and sanitize_callback incompatibility?
- post created but no permalink