Skip to content

Instantly share code, notes, and snippets.

View rodica-andronache's full-sized avatar
🦄

Rodica-Elena Irodiu rodica-andronache

🦄
  • themeisle.com
  • Bucharest
View GitHub Profile
@rodica-andronache
rodica-andronache / gist:8320074
Last active January 2, 2016 14:58
How to use yoast local plugin
<?php
pt o singura adresa in loc de id pun 'all'
!!!Asta e pt mai multe locatii:
if( function_exists( 'wpseo_local_show_map' ) ) {
$params = array(
'echo' => true,
'id' => 804, // this is the post id from the Albany post in the Locations CPT
'width' => 460,
'height' => 296,
'zoom' => 12,
@rodica-andronache
rodica-andronache / gist:7943120
Created December 13, 2013 11:42
WORDPRESS - Insert post from code
// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(8,39)
);
// Insert the post into the database
@rodica-andronache
rodica-andronache / gist:7943104
Created December 13, 2013 11:40
WORDPESS - Insert shortcode in code
echo do_shortcode('[gallery]');
@rodica-andronache
rodica-andronache / gist:7943096
Created December 13, 2013 11:39
WORDPRESS - Default widget
http://codex.wordpress.org/Function_Reference/the_widget
class My_Custom_Widget extends WP_Widget
{
/* your code* /
}
<?php the_widget( 'My_Custom_Widget' ); ?>
@rodica-andronache
rodica-andronache / gist:7942087
Last active December 31, 2015 05:39
Formular care trimite email
<?php
!!!!! Daca vreau ca pozitia in pagina sa fie retinuta si dupa submit:
<form method="POST" action="" onSubmit="this.scrollPosition.value=document.body.scrollTop">
<input type="hidden" name="scrollPosition">
<input type="submit" value="Send Message">
</form>
<body onLoad="window.scrollTo(0,<?php echo $_POST['scrollPosition'];?>)" <?php body_class(); ?>>
!!!!!
@rodica-andronache
rodica-andronache / gist:7481601
Last active December 28, 2015 09:49
Related posts - by tags and categories
<?php
$max_articles = 7; // How many articles to display
echo '<h3>Related Topics</h3><ul class="related-topics">';
$cnt = 0;
$article_tags = get_the_tags();
$tags_string = '';
if ($article_tags) {
foreach ($article_tags as $article_tag) {
$tags_string .= $article_tag->slug . ',';
@rodica-andronache
rodica-andronache / gist:7368434
Created November 8, 2013 09:15
Paginatie pagina cu custom post types (Ex: Portofolio)
<ul>
<?php
global $paged, $wp_query, $wp;
if ( empty($paged) ) {
if ( !empty( $_GET['paged'] ) ) {
$paged = $_GET['paged'];
} elseif ( !empty($wp->matched_query) && $args = wp_parse_args($wp->matched_query) ) {
if ( !empty( $args['paged'] ) ) {
$paged = $args['paged'];
}
@rodica-andronache
rodica-andronache / gist:7262964
Created November 1, 2013 09:21
CSS - Make text appear on two columns
-moz-column-count:2; /* Firefox */
-webkit-column-count:2; /* Safari and Chrome */
column-count:2;
@rodica-andronache
rodica-andronache / gist:7162111
Created October 25, 2013 21:27
WORDPRESS - Make a select with category list
<form action="<?php bloginfo('url'); ?>/" method="get">
<?php
$select = wp_dropdown_categories('show_option_none=Select Category&show_count=1&orderby=name&echo=0&selected=6');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><input type="submit" value="View" /></noscript>
</form>
@rodica-andronache
rodica-andronache / gist:7125902
Created October 23, 2013 20:15
Create a popup window that shows a form
http://buckwilson.me/lightboxme/
jquery.lightbox_me.js:
/*
* $ lightbox_me
* By: Buck Wilson
* Version : 2.3
*
* Licensed under the Apache License, Version 2.0 (the "License");