This what I am trying to do - source - http://www.torontostandard.com/
Is there any plugin for this look and feel ?
Code im using this time to fetch posts with featured tag.
However it would be better if I can loop using jquery, but unable to find any tutorial on this :(
<?php query_posts('tag=featured'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_post_thumbnail('thumbnail'); ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>
PS- Googled a lot for this plugin but unable to find any
I always find that if I want to steal a jquery plugin from a site I just look at the source and google the js files:
<script type="text/javascript" src="/js/libraries/jquery.scrollTo-min.js"></script>
however I always just build my own but that's me.
Related
Firstly, I'm a total beginner in this business but I decided to learn some php and now I'm trying to follow wordpress course .. which is by the way 5 years old. Anyway, I did the following code and it worked fine but vs code editor is saying that I am trying to use unknown function PHP(PHP0417).
The code is like this and according to vscode have_posts(), the_title(), the_content() is unknown function
Is the course outdated or what is going on?
<?php
while(have_posts( )) {
the_post(); ?>
<h2><?php the_title();?></h2>
<?php the_content();?>
<hr>
<?php }
?>
I'm trying to display the data of a ACF but I'm getting this error in Visual Studio Code:
This is the entire code. I tried reinstalling the plugin, added PHP to the path but nothing seems to be working.
Single.php
<?php get_header();?>
<div class="container">
<div class="row">
<div>
<img src="<?php the_post_thumbnail_url('thumbnail'); ?>" id="single_header">
<div id="single_content">
<?php if (have_posts()):while (have_posts()):the_post(); ?>
<?php
$fn=get_the_author_meta('first_name');
$lname=get_the_author_meta('last_name');
$email=get_the_author_meta('email');
?>
<h1 class="text=cenetr nt-3 mb-5 text-primary"><?php the_title();?></h1>
<small>Publishor:<?php echo $fn; ?></small>
<p><?php the_content();?></p>
<?php
endwhile;
endif;
?>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div>
<div id="single_extraInfo">
<p>Company: <?php the_field('flight_company'); ?></p>
<p>Date: <?php the_field('flight_date'); ?></p>
<p>Capacity: <?php the_field('flight_capacity'); ?></p>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
On top of what #DaleNguyen adviced above...
Make sure the directory that contains acf plugin is in your Vs Code. Example, instead of only opening the theme directory in Vs Code in which you are probably working, open the entire wp_content directory in your VS Code. That way, when intelephence run in the back-ground, it will be able to reach the plugins folder and acf functions in the acf plugin folder.
In the intelephense, make sure you add wordpress to the list.
#james-serengia answered with one working solution that the ACF plugin folder should be open in the same workspace as the code you are working on and the warning disappears.
Alternatively if that is inconvenient, you can add you can add the ACF stubs to VSCode. It is a bit of messing around but when it is done, it is done. See this explanation.
I am playing around with WordPress and trying to learn what it can and can't do. I am trying to change the font color from black to white in the index.php file.
I can change the background colour of the the_title(), that works but changing the colour of the the_content() does not seem to work.
I tried googling but haven't found much help about using CSS with PHP, if anyone knows a good page I could read that would be much appreciated.
Here is the code (Please excuse the formatting):
<?php if (have_posts()) : while ( have_posts() ) : the_post();?>
<p style="color:white"><?php the_title(); ?></p>
<p style="color:white"><?php the_content(); ?></p>
<?php endwhile;
else : ?>
<p>Sorry no posts matched your criteria.</p>
<?php endif;?>
Content of a post is html and it contain many elements like h2, h3, p, a.
So if you want to apply css into its children tag:
<div style="color:white"><?php the_content(); ?></div>
I am running a Wordpress site and created a custom theme.
Now I'm stuck with optimizing it for Google PageSpeed. It shows the following for the Mobile page:
Consider Fixing: Only about 63% of the final above-the-fold content could be rendered with the full HTML response
This appears since I've included the Featured Image above my posts on the index.php with the code:
<p>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
</p>
How can I fix the issue? It doesn't seems to me that I'm loading something like a sidebar before the featured image, apart from the logo of the site. For a deeper comprehension, here the complete code of my index.php
<?php get_header(); ?>
<div id="main">
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<p>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
</p>
<h1>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h1>
<p>
<?php the_content(__(' <br /> <br /> Weiterlesen →')); ?>
</p>
<hr>
<?php endwhile; else: ?>
<p>
<?php _e('Sorry, no posts matched your criteria.'); ?>
</p>
<?php endif; ?>
<?php if (show_posts_nav()) : ?>
<div class="pagination">
<?php echo paginate_links(); ?>
</div>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<div id="delimiter">
</div>
<?php get_footer(); ?>
Can someone help me with this issue? What am I doing wrong?
As someone who holds a 100/100 pagespeed score, I can tell you that over-optimizing for speed is probably not worth the frustrations you're going to run into fixing the problems. Case in point, run a Pagespeed test on Wikipedia or YouTube. These are top sites and YouTube only has a score of 50, for example. The real reason you'd want to improve these numbers is to provide a better experience to users because they don't have to wait for the page to load.
Your above the fold content is simply what is allowed to be displayed while waiting on additional resources to load:
Your page has 4 blocking script resources and 2 blocking CSS resources. This causes a delay in rendering your page.
None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.
Remove render-blocking JavaScript:
/…-includes/js/jquery/jquery.js?ver=1.11.3
/…s/jquery/jquery-migrate.min.js?ver=1.2.1
/…ghtbox/jquery.touchwipe.min.js?ver=1.4.6
/…ightbox/jquery.lightbox.min.js?ver=1.4.6
Optimize CSS Delivery of the following:
/wp-content/themes/1000PB/style.css
/…ghtbox/styles/lightbox.min.css?ver=1.4.6
Your efforts are best spent optimizing the delivery of these, (using async or defer for scripts and stylesheets) since those will lower your overall pagespeed score and hurt your search engine rankings.
To answer your question, though, you can inspect elements that are towards the top of your page, generally anything that can be seen without scrolling down, to see their css. Example:
img.attachment-post-thumbnail {
border: 1px solid #e6e6e6;
padding: 3px;
}
So that stuff is best included in an inline <style> element in the header, as then the browser won't have to wait for style.css to load before it can show the page to users.
If you need help with hacking your Wordpress theme to do certain things to make it faster, such as minifying scripts, making scripts asynchronous, using defer, disabling emoji, and so on, just ask in comments or submit another question and we will be glad to help.
I recommend testing on other sites to get a better idea of what's going on. I recommend Webpagetest.org and using a Waterfall chart will tell you which resources are taking the longest:
You can also use tools to help with this:
CSS Tricks: Authoring Critical Above-the-Fold CSS
Critical-path (Above-the-fold) CSS Tools
I have installed the redux option framework into my theme and made it work so things change when I add the sample config file. (and when I do print_r($redux_demo); in functions.php I get a wall of text at the top)
Problem I have is that I want to make it work in my theme. So I bought two other theme that use redux (seashell by meks and total by WPExplorer) to get some knowledge how to implement it but I just don't get it :(
I'm newbie to php and I wonder of you guys could explain how to do this with redux?
<?php if (something): ?>
<h1>It Works!!!</h1> <?php endif; ?>
I see that Seashell template do something like this:
<?php if($favicon = shl_get_option('favicon')): ?>
<link rel="shortcut icon" href="<?php echo $favicon;?>" type="image/x-icon" />
<?php endif; ?>
So I want to just link the if statement to the "demo switch" (ID: switch-on) and make it work.
<?php if ($redux_demo('switch-on')): ?>
<h1>It Works!!!</h1>
<?php endif; ?>
How do you do this? :)
Just saw this question, I'm surprised it had no answer.
<?php if (true == $redux_demo('switch-on')): ?>
<h1>It Works!!!</h1>
<?php endif; ?>
(note the use of Yoda conditions as well, which avoids accidentally introducing a tricky bug if you mistype an == as =)