To insert new code you need to break php code and past your new html+/-php code. But pay attention that after passing all will have correct syntax.
Your question should be made like this:
<?php $my_query = new WP_Query( "cat=11&posts_per_page=1" );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$my_query->the_post(); ?>
<h2><a href="https://wordpress.stackexchange.com/questions/53008/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="postdetails">
Written by <strong><?php the_author(); ?></strong>
<?php the_time ('j F, Y'); ?>
Posted in: <strong><?php the_category(', '); ?></strong>
<?php the_tags(); ?>
</div>
<?php the_excerpt();
}
}
wp_reset_postdata(); ?>
Related Posts:
- Limit the Excerpt field in WP-Admin in words
- Multiple choice in a custom taxonomy
- Error when adding excerpt to the content through functions.php
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- List of Events with Multiple Dates: Only NEXT Date
- Assign Custom classes to every Excerpt
- How can I check that the acf field value is not a duplicate when adding a post?
- Trying to modify content.php
- Show content by using tags
- Check if values exists DB
- Receiving Stripe Webhooks on a wordpress website
- wpdb::prepare was called incorrectly
- What would be a PHP command to erase all posts from category X from the last month?
- Walker class: Problems with understanding how walk() method can be called without error
- How to Use the Function is_user_logged_in To Display Different Menus?
- Change comments form title on a page by page basis
- Add value to usermeta without removing previous values?
- Setting up the child theme so as to enable right-to-left WordPress?
- String replace WordPress Site Title
- my function doesn’t return my post from today
- Type hinting and void return question
- Extremely slow pageload for long post when using the_content?
- Customized title tag for each page in pagination?
- Display related products with custom output
- How to break down importing of feeds
- Excerpt unwanted text “”
- Word Count Function Preventing Permalink Editing
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Get stock by custom meta field on all Woocommerce variable products
- How do I Add HTML to the_excerpt() & the_content() Output?
- WP dynamic featured image – Can’t get second featured image url
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- Send an email to specific adress when button is clicked?
- Customizer: active_callback and sanitize_callback incompatibility?
- Redirect specific user role to specific site after login?
- Send multiple attachments with wp_mail in PHP
- Long running queries
- How to get the value of input hidden html from text editor to custom page template?
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- register_taxonomy() take much queries
- how to show only specific category for a template
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Odd / Even posts add class minus first post
- How to get private property in parent class into extended class?
- How to add div blocks after certain set of post
- Clickable image link sends people to wrong URL
- Create page template via functions.php?
- WordPress query undefined offset in loop
- Issue with custom loop in Archive page
- How to include custom PHP file both in header and footer files
- Parse error: syntax error, unexpected ‘}’ [closed]
- Display an image based on field value
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- Update if post with specific title exists
- Reusable code that I can store in the function.php and apply to other templates as need. Dry Code
- How to get thumbnail with pure PHP in a WordPress database?
- mySQL queries are executed twice on wordpress website
- Make next post button link to random post
- WordPress Twenty Eleven PhP – forcing php code to skip first post on homepage?
- pass html code to worpdress
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Query pulling a single post per month
- Site DOES NOT LOAD after 3.1 update
- How can I modify this code to make the search box include tags and meta
- For some time, some of my pages do not display the content anymore. Any idea where this could be coming from?
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Customizer control save then return to default
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- update_user_meta as multiple value but with same meta key
- Inserting a class on before_widget if checkbox is checked
- Delete post meta by serialized meta value
- Dynamic Banner Text based on Subdomain
- Redirecting the lost password page request when using a custon login page
- Create custom admin page with custom text fields
- Remove specific javascript when viewing page in Customizer?
- Running local copy of an old WordPress site on MAMP
- How to query a staging database?
- How to make a parent page for author.php?
- Customizing WooCommerce with PHP
- Multisite – Display different header content based on which site is accessed
- What image is this pulling?
- How to apply filter
- Include a custom field in mysql query
- How to use PHP code with wordpress page
- if is_bbPress register jquery
- Auto create description in post
- Creating a function that sanitizes the custom metabox excerpt
- error with WP custom form
- How can I clear the theme mod settings?
- Custom PHP-coding in MU installs
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- HTML in PHP problem [closed]
- wp_query on search results page showing all results every time
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- Three different queries on same page
- generate excerpt from the part of big text dump that contains keyword
- Exclude a category ID from the following function