You’ve wrapped the opening and closing of the while
in separate if
statements. This is the structure of your code.
if( $term ) {
// etc.
while ( $loop->have_posts() ) :
}
// etc.
if( $term ) {
endwhile;
}
This is not valid PHP. You need to structure it like this:
if( $term ) {
// etc.
while ( $loop->have_posts() ) :
// etc.
endwhile;
}
Related Posts:
- Can i use php sql functions instead of $wpdb?
- Why include a composer.json file with my plugin?
- Getting paginate_links() ‘end_size’ to display none
- What is the best practice for escaping data URIs?
- WordPress Template Engine?
- Display only text to WordPress loop without loosing the text formatting
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- How do I get images (with a thumbnail preview) to show in search results?
- How to display blog images using wordpress in existing project
- How do I translate this string – PHP syntax question
- PHPCS: Strings should have translatable content
- mysqli_real_connect() – authentication method unknown to the client Warnings
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- how to increase custom post value by one most efficiently?
- multiple if statements [closed]
- Escape post image attachments added to template
- Woocommerce product download URL
- Multiple choice in a custom taxonomy
- Calculations in functions.php [closed]
- Echo URL of large version of Featured Image
- Get_avatar filter?
- WordPress custom login form using Ajax
- WP dynamic featured image – Can’t get second featured image url
- Why is my cookie not unsetting upon logout? [closed]
- How to remove role=”navigation” from all nav elements?
- How to use $_GET function WordPress backend
- How to set variable, pass it to a partial file and remove it after?
- Dynamic content in template
- wp_dropdown_pages auto submit
- WooCommerce Tabs [closed]
- Limit checklist by the current user
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Change page title from page using php via php executed from page/post itself
- Download images from media library to computer in BULK?
- How to array only one key from another array
- Detecting if parent page has gallery
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Location of core code for database connection and get_header
- Removing WordPress Footer -without access to PHP code?
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Plugin development and composer
- WC_Customer delete function returns error
- Delete or edit postmeta with specific meta_key?
- Post repeated when opening in overlay, how do I solve this? [closed]
- Woocommerce: remove total sum from new order’s email [closed]
- Trying to display text in a block in a plugin page
- Some menu items wont budge
- Removing “Powered by” footer using child theme PHP [closed]
- custom post type with role Vendor
- how to hide or disable some part in specify page
- Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(“
- Include a file that has a function in it
- Trying to split a query into sections of six
- Kohana Frontend, WordPress Backend
- making my own “related pages” / “pages you might like” section
- apply_filters with several different values?
- Show ranking based on post id
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- Contain multiple page templates in one PHP custom template file in WordPress?
- url not using query string no longer working
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Display div if category has a specific parent
- Custom plugin: how do I call a PHP file if settings option is set to true?
- I want it to detect the duplicate comment and give a warning on the same page
- How to edit button permalink inside function.php using a child theme?
- How to switch between two primary menus (programatically0
- Why am I getting syntax error, unexpected ‘endwhile’ (T_ENDWHILE) on single.php
- Elementor to custom wordpress page
- custom post type not showed with bootstrap 4 modal and template part
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Shortcode just with a php code
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- wp_send_json erase last value
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- I want show only data for today
- How can I customize a WordPress theme before it’s downloaded?
- Permalinks and custom PHP application
- rewrite_rule – working fine but broken for pagination
- AdWords API with WP
- Add title and caption to thumbnail image on mouseover
- Postmeta not saving
- WordPress wp_remote_post() sending informaiton to Redmine REST API
- Missing items on page
- WordPress rewrite question
- WordPress blog set up
- Cannot get custom javascript to execute on page
- How to declare a variable at the bottom of the page and use its value at the top?
- Shortcode working in page.php but not in category.php in wordpress
- How can a ‘scripts’ directory be hooked into wp_head();?
- Display Current Time using shortcode
- WP and Laravel integration (Updated) [closed]
- How to pass javascript var to php var