mattlitzinger
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Rendering a php/html page with dataHi @janmoes
I would use the
$_SERVER['PHP_SELF']
variable as the form action attribute, so the form posts to itself. This is described in greater detail in this tutorial. This would allow you to test the input values after the form is submitted and render any error messages or a success state.<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" > ... </form>
Hope that helps.
- This reply was modified 3 years, 1 month ago by mattlitzinger.
- This reply was modified 3 years, 1 month ago by mattlitzinger.
Forum: Developing with WordPress
In reply to: Disabling Gutenberg Duotone Filter?Hi @jhamilt2
If you’re running 5.8, you should be able to disable the duotone settings completely using the new
theme.json
configuration. Assuming you don’t already have settings defined intheme.json
, the file would look something like this:{ "version": 1, "settings": { "color": { "duotone": [], "customDuotone": false } } }
More details on
theme.json
usage can be found here.- This reply was modified 3 years, 1 month ago by mattlitzinger.
Forum: Fixing WordPress
In reply to: Display latest posts..You will need to either print your HTML code using PHP echo or close your PHP tags before starting to write HTML. For example:
if ( $first_post ) { ?> <div class="post featured-post">First Post</div> <?php } else { ?> <div class="post">Post</div> <?php }
That can be easily overlooked and would lead to the issue you’re describing.
Forum: Fixing WordPress
In reply to: Display latest posts..Sorry to hear that. Is the code you posted above the most up-to-date version you’re working with? I’m not seeing anything wrong there. If the template already includes the default
while(have_posts())
that’s fine to use instead of creating a customWP_Query
. If you can post the latest code you’re working with I could take a look.Forum: Fixing WordPress
In reply to: Display latest posts..This is template code, so it would be placed in your
index.php
orarchive.php
template file depending on your needs. If you wanted afunctions.php
solution, you could use something like the following which would just add a.first
class name to the first item in the loop. You could then use that class to apply CSS to only that element.<?php add_filter( 'post_class', 'wps_first_post_class' ); function wps_first_post_class( $classes ) { global $wp_query; if( 0 == $wp_query->current_post ) $classes[] = 'first'; return $classes; } ?>
- This reply was modified 3 years, 2 months ago by mattlitzinger.
Forum: Fixing WordPress
In reply to: Display latest posts..Yes, this is possible. You’ll need to create a variable before looping through the posts:
$first_post = true;
. The conditional within the loop checks if it’s the first post and displays different HTML markup if that’s the case. Then after looping through for the first time, set the$first_post
variable tofalse
.If this is for your main blog page, these changes would be made to the
index.php
template file within your theme.$query_args = array( 'post_type' => 'post' ); $posts_query = new WP_Query( $query_args ); if ( $posts_query->have_posts() ) { $first_post = true; while ( $posts_query->have_posts() ) { $posts_query->the_post(); if ( $first_post ) { // Put your HTML markup for the first post here } else { // Put the HTML markup for all other posts here } $first_post = false; } } wp_reset_postdata();
Forum: Themes and Templates
In reply to: Widgets Position on Install of Custom ThemeThis thread is closed.
Forum: Themes and Templates
In reply to: Widgets Position on Install of Custom ThemeHere is the code I used to acheive this. Just add the following inside each sidebar where you want to add default content.
<?php if ( ! dynamic_sidebar( 'sidebar-5' ) ) { the_widget( 'WP_Widget_Calendar' ); } ?>
Source: https://stackoverflow.com/questions/10203413/how-to-add-default-widgets-to-a-custom-dynamic-sidebar
Forum: Themes and Templates
In reply to: Widgets Position on Install of Custom ThemeCascus,
Thanks for your reply, but this is something I would like to happen from a clean install.Forum: Themes and Templates
In reply to: Widgets Position on Install of Custom ThemeThanks, I am calling the widgets from a file called footer-sidebar.php. The widgets load fine, but the all load in the first column. I would like them to be spread out over three columns on install.