Display Blogtitle in HTML-Textfield - html

On my wordpress site on the sidebar I have a text widget. I want do display the blogname (blogtitle) there. I want an HTML code, that crab and show the blogtitle by itself. I tried with this code but nothing happened:
<?php bloginfo('name'); ?>
I searched on Google but didn't find anything useful.
Can someone help me please?

When given the 'name' as parameter Wordpress looks for “Site Title” set in Settings > General. Check if this is set.

Related

How to make a custom Archive page with Wordpress using custom post types and acf fields

I am building a child theme on GeneratePress to create a custom site for a client and am stuck on customizing the Archive pages. I've determined that it will be best to ignore the theme functionality and build the page loops from scratch. The custom archive should take the place of wp/generatepress' standard archive page and function in the same way by showing relevant posts when a taxonomy term is clicked. I need to be able to choose which html tags are used and style them with css. My issue is that I don't understand wordpress dev enough to figure out how to do this.
I have two custom post types, Research and Resources, as well as a bunch of different custom taxonomies that are applied to both or each post type. I'd like to customize the archive page (with archive templates if necessary) so it displays the appropriate Research and/or Resource files when visited.
I understand that I need to loop through all the posts, but I do not know how to grab only the relevant ones per the given archive page.
Examples of loops with example content will be the most helpful. Thank you!!
I chatted with someone on Reddit who kindly answered this question for me here.
They said:
So I wouldn't do it as a template personally (you could), I would do it through having two new files a archive-research.php & archive-resources.php.
Then if the loop is going to be the same on both pages, which I think you said it is going to be (you just want to display the posts from each custom post type), I would use a template part.
So create a new folder in your theme folder called inc or includes and name the file custom_post_loop.php (name can be anything).
Then in your archive page, call...
<?php get_template_part('inc/custom_post_loop');?>
In that file you are just wanting to write a simple post loop in there.
while ( have_posts() ) : the_post();
// Your loop code
// just so you can see this work I have called the title
the_title();
endwhile;
else : _e( 'Sorry, no posts were found.', 'textdomain' ); endif; ?>
https://developer.wordpress.org/reference/functions/have_posts/
Have a look at that link to find out more. But thats the direction to go...
If you really wanted to got the direction you have with the template, you would have to add arguments to your posts loop.
it works the same way but instead of archive.php its taxonomy.php...
However, you don't want a taxonomy-{taxonomy name}.php file for each taxonomy as that would be ridiculous unless you knew all the taxonomies haha and had really specific user cases for them...
so just create a taxonomy.php in your theme files and to make sure its working just add this code to it...
<?php get_header();>
<h1><?php the_archive_title();?></h1>
//then put your loop in from earlier...
<?php get_template_part('inc/custom_post_loop');?>
<?php get_footer();?>

Cakephp 3 Element file is missing

I have the problem that my navbar.ctp element isnt loading i only get the error message from cakephp
Element file "Element/navbar.ctp" is missing.
My code in my default layout of cakephp (because i want the navbar in all "views")
<?php
echo $this->element('navbar');
?>
and my element is in Layout/Element/navbar.ctp
So i dont unterstand why it says me that my element is missing.
Do i have anything missing?
I hope someone could help me with the problem. I dont have much information, because its not complicated per se.
I think you have the file in the wrong folder.
Check the cookbook:
Elements live in the src/Template/Element/ folder, and have the .ctp
filename extension. They are output using the element method of the
view:
echo $this->element('helpbox');
Source: https://book.cakephp.org/3/en/views.html#elements

WORDPRESS: add_theme_support( 'post-thumbnails' ); doesn't work?

I'm customizing a wordpress theme. And now, my theme doesn't have Feature Image function.
I've tried reading https://codex.wordpress.org/Post_Thumbnails and found out that I need to add the line: add_theme_support( 'post-thumbnails' ); to the function.php and hope that "If your theme was successful in adding support for Post Thumbnails the "Featured Image" metabox will be visible on the on the Edit Post and Edit Page screens." as they said in codex.wordpress... But the magic didn't happen.
I've tried mimicking the TwentyTwenty theme for that but didn't succeed. Also found a lot of asked question here but didn't help much.
I don't know if some more steps needed? Could you please help me out? Thank you in advance.
Luckily I fixed my problem.
- The right name of the file functions.php is in plural noun (functions).
- Including <?php and ?> helps.
I know it maybe basic knowledge. I just post here so that perhaps it is useful for someone.
Full working code for functions.php:
<?php
add_theme_support( 'post-thumbnails');
set_post_thumbnail_size( 50, 50 );
?>
add_theme_support('post-thumbnails');
please look at the syntax correctly sometimes you may write post_thumbnails and get stuck.
it's
post-thumbnails
not
post_thumbnails

Understanding wordpress the_content

I have been asked to tweak a friend's website. The website was built for them using Wordpress by an agency they no longer work with. Problem is, I don't know very much about Wordpress, so I have some basic questions…
I can see (by comparing the source as viewed in my browser to the php templates that I can edit through the Wordpress interface) that the elements I need to modify are generated by the page's call to "the_content()". I don't really understand what this function does, but I think it pulls content for a given page from the MySQL database. Is that right?
I suspect that the Wordpress interface alone won't be enough to let me modify elements that come out of that database. Is that correct? How does anyone change, for example, the specific arrangement of text and images on a page if the relevant markup is fetched by "get_content()"?
When developing for WordPress or even just tweaking, it's really important to get at least a general understanding of the "loop" and how we use it for output. In order to output the content you need to call the method within the loop. If it's not within the loop it won't get inserted into your page.
(It works this way with all of your pages... index.php, page.php, single.php, post.php, etc... Your methods need to be placed within the loop in order for them to display within that page.)
Here's a simple example of the way the loop is used to output the title and content of posts:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> // loop start
<h1><?php the_title() ;?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?> // loop end
<p>Sorry, this page does not exist</p>
<?php endif; ?>
If you take a look at any standard WordPress theme (take Twenty Fourteen, for example), you'll find that the_content() is output together with calls to other elements (in this case - the_title()). If you want to want to change the arrangement of the specific elements within your page, just modify the order as they are within your loop, or check the WordPress Codex for additional options/methods.
Here's a short list of some other things you can display:
next_post_link – Displays a link to the post published chronologically after the current post.
previous_post_link – Displays a link to the post published chronologically before the
current post.
the_category – Displays the category or categories associated to the post or page being viewed.
the_author – Displays the author of the post or page.
the_content – Displays the main content for a post or page.
the_excerpt – Displays the first 55 words of a post’s main content then with a [...] or read more link that goes to the full post. The length of excerpts can be controlled by using this slightly advanced method or by using the Excerpt field on the post edit page.
the_ID – Displays the ID for the post or page.
the_meta – Used to display custom fields.
the_shortlink – Displays a link to the page or post using the url of the site using
the ID of the post or page.
the_tags – Displays the tag or tags associated with the post.
the_title – Displays the title of the post or page.
the_time – Displays the time or date for the post or page. This can be customized using the standard php date function formatting.
If you want to further customize some of these methods, you can do that within functions.php. Otherwise, all styling is done within your styles.css.
Probably your content is being generated by a shortcode.
You can modify the content that wordpress fetches from the database with the_content filter:
// returns the content of $GLOBALS['post']
// if the page is called 'debug'
function my_the_content_filter($content) {
// assuming you have created a page/post entitled 'debug'
if ($GLOBALS['post']->post_name == 'debug') {
return var_export($GLOBALS['post'], TRUE );
}
// otherwise returns the database content
return $content;
}
add_filter( 'the_content', 'my_the_content_filter' );
maybe its not the best solution but you can modify the content before it gets output.
source

dynamic link to sub page meta description

I am new to web page development. Something I would like to do, is create a link to a sub-page, and have the text part of the link display the meta description of the sub-page dynamically. So if at some point I update the description of the sub page, then refresh the browser on the main page, that updated description will display automatically in the link. Any idea how to do that?
You will need php for this. Something like
<?php
$tags = get_meta_tags('http://www.yousite.com/');
$content = $tags['description'];
echo "".$content."";
?>