• 0765 849 800
  • contact@code-evolution.ro
  • Acasă
  • Ce facem
    • Web Development
    • Optimizare S.E.O.
    • Promovare Google Ads
    • Social Media Marketing
    • Fotografie Comercială
  • Blog
  • Cum dai de noi
  • Acasă
  • Ce facem
    • Web Development
    • Optimizare S.E.O.
    • Promovare Google Ads
    • Social Media Marketing
    • Fotografie Comercială
  • Blog
  • Cum dai de noi
  • Acasă
  • Ce facem
    • Web Development
    • Optimizare S.E.O.
    • Promovare Google Ads
    • Social Media Marketing
    • Fotografie Comercială
  • Blog
  • Cum dai de noi

WordPress Cheat Sheet – Anatomia unui template si functii de baza

  • Home
  • Wordpress
  • Wordpress Cheat Sheet – Anatomia unui template si functii de baza
WordPress Cheat Sheet – Anatomia unui template si functii de baza
  • 20/10/2025
  • Wordpress

Fisierele unui template WordPress

style.css // Theme’s main stylesheet file
index.php // Main template file
single.php // Single post file.
          // ..Used for to display single posts only
archive.php // Archive or Category template file
searchform.php // Search form file
search.php // Search results file
404.php // 404 error page file.
        // ..Will be displayed if no page can be found.
comments.php // Comments template file
footer.php // Footer content file
header.php // Header content file
sidebar.php // Sidebar content file
page.php // Single page file. Used for pages only 

"Anatomia" unui template WordPress

// header.php
get_header();
wp_nav_menu(); //(registered in functions.php)
get_search_form();

// The Loop
index.php
home.php
archive.php
page.php
single.php
comments_template();
search.php
author.php
404.php

// sidebar.php
get_sidebar();

// footer.php
get_footer();

// Others
style.css // Theme style
functions.php // Theme functions
comments.php // Comments template
 

WordPress Template Tags

O serie de functii folosite in cadrul unui template WordPress

Template tag-urile reprezinta un set de functii ce au rolul de a prelua continutul din baza de date si a-l afisa in cadrul unui template (si nu numai). Continutul poate fi orice, de la titlul blogului pana la un sidebar complet. Aceste functii (template tags) :

  • au rolul de a afisa continut in cadrul unei teme de WordPress intr-un mod dinamic
  • pot fi folosite in cadrul mai multor fisiere din tema
  • cu ajutorul lor poti imparti continutul unui template in sectiuni mai mici si mai usor de inteles
the_content(); // Get post content
the_excerpt(); // Get the post excerpt
the_title(); // Get the title of the post
the_permalink(); // Display post link
the_category(','); // Display category of a post
the_author(); // Show post author
the_ID(); // Display post ID
edit_post_link(); // Show Edit link for a post
next_post_link('%link'); // Display next page URL
previous_post_link('%link'); // Display previous page URL
get_links_list(); // Retrieve blogroll links
wp_list_pages(); // Retrieve all pages
wp_get_archives(); // Retrieve archive for the site
wp_list_cats(); // Retrieve all categories
get_calendar(); // Show the built-in WordPress calendar
wp_register(); // Show register link
wp_loginout(); // Displays login or logout links (for registered
users) 

Include Tags

O serie de functii ce includ in cadrul unui template diferite sectiuni

<?php get_header(); ?> Includes header.php and display its content
<?php get_sidebar(); ?> Includes sidebar.php
<?php get_footer(); ?> Includes the footer.php
<?php comments_template(); ?> Load specific template for comments 

Functii utile

Folosite in cadrul header-ului template-ului

site_url(); // Get WordPress site url
wp_title(); // Get page title
bloginfo('name'); // Get blog name
bloginfo('description'); // Get blog description
get_stylesheet_directory_uri(); // Get stylesheet directory URI
bloginfo('atom_url'); // Get Atom feed URL
bloginfo('rss2_url'); // RSS 2.0 URL 

The Loop (bucla)

Loop-ul (bucla) reprezinta mecanismul implicit al WordPress folosit in afisarea continutului unui articol (post) prin intermediul fisierelor template.

<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
// Display post content
<?php endwhile; ?>
<?php endif; ?> 

Meniul din Wordpres / Bara Laterala (Sidebar)

Default Navigation Menu
<?php wp_nav_menu(); ?>

Specific Navigation Menu
<?php wp_nav_menu( array(‘menu’ => My Navigation’ )); ?>

Category Based Navigation
<ul id=”menu”>
     <li <?php if(is_home()) { ?> class="current-cat" <?php } ?>>
          <a href="<?php bloginfo('home'); ?>">Home</a>
     </li>
     <?php wp_list_categories('title_li=&orderby=id');?>
</ul>

Page Based Navigation
<ul id="menu">
     <li <?php if(is_home()) { ?> class="current-cat" <?php } ?>>
          <a href="<?php bloginfo('home'); ?>">Home</a>
     </li>
     <?php wp_list_categories('title_li=&orderby=id');?>
</ul>

Registering New Sidebar
Add the following code to your functions.php file to register a new sidebar.
<?php 
add_action( 'widgets_init', 'theme_slug_widgets_init' );

function theme_slug_widgets_init() {
     register_sidebar( array(
          'name' => ( ‘
         'My Sidebar', 'theme-slug' ),
          'id' => 'sidebar-1',
          'description' => ( 'Description', 'theme-slug' ),
          'before_widget' => '<li id="%1$s" class=”widget %2$s">',
          'after_widget' => '</li>',
          'before_title' => '<h2 class="widgettitle">',
          'after_title' => '<h2>',
     ));
} 
monetizare pe youtube
Previous Post

Cum iti poti monetiza muzica pe YouTube in 2022?

Next Post

Woocommerce – Ghid vizual action hooks – Shop/Categorie de produse/Arhive de produse

Caută

Categorii

  • Ghiduri Vizuale
  • Marketing
  • PHP Snippets
  • S.E.O. Onpage
  • Technical S.E.O.
  • Woocommerce
  • Wordpress
  • YouTube

Articole recente

10/01/2023
Ce este Black Hat S.E.O.
monetizare-youtube-shorts
09/01/2023
Monetizare YouTube Shorts: ia-ți doza de
09/01/2023
Ce este White Hat S.E.O?
06/01/2023
Ce este formatul WebP pentru imagini?
03/01/2023
Importanta tag-urilor de tip meta title
  • shape1
  • shape2
  • shape3
  • shape4
  • shape5
  • shape6
  • shape7

Abonare la newsletter!

    Link-uri utile

    • Portofoliu
    • Blog
    • Contact
    • Politica de cookies
    • Politica de confidentialitate si securitate

    Servicii

    • Web Development
    • Optimizare S.E.O.
    • Promovare Google Ads
    • Social Media Marketing
    • Servicii de Fotografie Comerciala

    Contact Rapid

    • 0765 849 800
    • contact@code-evolution.ro
    © Code Evolution
    • Acasă
    • Ce facem
      • Web Development
      • Optimizare S.E.O.
      • Promovare Google Ads
      • Social Media Marketing
      • Fotografie Comercială
    • Blog
    • Cum dai de noi
    FREE ANALYSIS
    • Acasă
    • Ce facem
      • Web Development
      • Optimizare S.E.O.
      • Promovare Google Ads
      • Social Media Marketing
      • Fotografie Comercială
    • Blog
    • Cum dai de noi