vipsol1n

Рейтинг
34
Регистрация
01.09.2013

А где теперь это расширение найти то, если в магазине хрома его нету?

Malcolm, спасибо получилось, а как это сделать с nofollow

Движок wordpress 4.0.1

Неужели никто не может помочь а, отвечают только на легкие вопросы типа какой движок выбрать, а на реальные вопросы никто не отвечает

Как сделать, чтобы на главной странице в сайдбаре были открыты для индексации Новые статьи, а когда переходишь в рубрику, статью и т.д. то они уже были закрыты от индексации.

Wordpress 3.6

[spoiler][/spoiler]

Как сделать при размещении статьи показывало автоматическое содержание по загалокам. И чтобы содержание показывалось после 1 абзаца, как на примере.

Нужно, чтобы содержание статьи показывалось после 1 абзаца, как это сделать ?

Может в плагине что-то изменить?

Вот код плагина содержания:

<?php
/*
Plugin Name: Marafon.Contents
Version: 0.1
*/

define('MK_CONTENTS_DEEPEST_H', 3);
define('MK_CONTENTS_AT_LEAST', 2);

function mk_contents_get_last_ind($id) {
$pos = strrpos($id, '-');
if ($pos === false) {
return false;
}
return intval(substr($id, $pos + 1));
}

function mk_contents_truncate_last_ind($id) {
$pos = strrpos($id, '-');
if ($pos === false) {
return false;
}
return substr($id, 0, $pos);
}

function mk_contents_increment_last_ind($id) {
$t = mk_contents_get_last_ind($id);
if (!$t) {
return false;
}
$id = mk_contents_truncate_last_ind($id);
$id .= '-' . ($t + 1);
return $id;
}

function mk_contents ( $content = '' ) {
if ( is_single() ) {
if (preg_match_all('|<h([0-9]+)([^>]*)>(.*?)</h|ims', $content, $m)) {

$n = sizeof($m[0]);

// Checks for the needed amount of headers.
$cnt = 0;
for ($i = 0; $i < $n; $i++) {
$m[1][$i] = intval($m[1][$i]);
if ($m[1][$i] <= MK_CONTENTS_DEEPEST_H) {
$cnt++;
}
}
if ($cnt < MK_CONTENTS_AT_LEAST) {
return $content;
}

$initial_content = $content; // Saves the initial content of the post. It is returned whenever some error occurs.
$contents = ''; // For li-elements of the final contents.

//print_r($m);

$prev_h = 1;
$id = 'part';
for ($i = 0; $i < $n; $i++) {
$cur_h = $m[1][$i];
if ($cur_h > MK_CONTENTS_DEEPEST_H) {
continue;
}

// Defines the id (part-...).
if ($cur_h > $prev_h) { // deeper level
$id .= '-1';
} elseif ($cur_h == $prev_h) { // the same level
$id = mk_contents_increment_last_ind($id);
} elseif ($cur_h < $prev_h) { // higher level
for ($t = 0; $t < $prev_h - $cur_h; $t++) {
$id = mk_contents_truncate_last_ind($id);
}
$id = mk_contents_increment_last_ind($id);
}
if (!$id) { // some error
return $initial_content;
}

// Adds the link to the contents.
$contents .= '<li class="cont' . $cur_h . '"><a href="#' . $id . '">' . $m[3][$i] . '</a></li>' . "\n";

// Adds the 'id' attribute to the header.
/*$content = str_replace(
$m[0][$i],
'<h' . $m[1][$i] . ' id="' . $id . '"' . $m[2][$i] . '>' . $m[3][$i] . '</h',
$content
);*/

// Another approach - with anchors (JLady).
$content = str_replace(
$m[0][$i],
'<p><a name="'. $id . '"></a></p>' . "\n" . $m[0][$i],
$content
);

$prev_h = $cur_h;
}

$content = '<p><b>Содержание статьи:</b></p>' . "\n\n"
. '<ul class="contents">' . "\n" . $contents . '</ul>' . "\n\n"
. $content;

}
}
return $content;
}

add_filter('the_content', 'mk_contents', 10);

?>

Требуется помощь все еще

Движок WP,

<?php

/*
Plugin Name: Marafon.Contents
Version: 0.1
*/

define('MK_CONTENTS_DEEPEST_H', 3);
define('MK_CONTENTS_AT_LEAST', 2);

function mk_contents_get_last_ind($id) {
$pos = strrpos($id, '-');
if ($pos === false) {
return false;
}
return intval(substr($id, $pos + 1));
}

function mk_contents_truncate_last_ind($id) {
$pos = strrpos($id, '-');
if ($pos === false) {
return false;
}
return substr($id, 0, $pos);
}

function mk_contents_increment_last_ind($id) {
$t = mk_contents_get_last_ind($id);
if (!$t) {
return false;
}
$id = mk_contents_truncate_last_ind($id);
$id .= '-' . ($t + 1);
return $id;
}

function mk_contents ( $content = '' ) {
if ( is_single() ) {
if (preg_match_all('|<h([0-9]+)([^>]*)>(.*?)</h|ims', $content, $m)) {

$n = sizeof($m[0]);

// Checks for the needed amount of headers.
$cnt = 0;
for ($i = 0; $i < $n; $i++) {
$m[1][$i] = intval($m[1][$i]);
if ($m[1][$i] <= MK_CONTENTS_DEEPEST_H) {
$cnt++;
}
}
if ($cnt < MK_CONTENTS_AT_LEAST) {
return $content;
}

$initial_content = $content; // Saves the initial content of the post. It is returned whenever some error occurs.
$contents = ''; // For li-elements of the final contents.

//print_r($m);

$prev_h = 1;
$id = 'part';
for ($i = 0; $i < $n; $i++) {
$cur_h = $m[1][$i];
if ($cur_h > MK_CONTENTS_DEEPEST_H) {
continue;
}

// Defines the id (part-...).
if ($cur_h > $prev_h) { // deeper level
$id .= '-1';
} elseif ($cur_h == $prev_h) { // the same level
$id = mk_contents_increment_last_ind($id);
} elseif ($cur_h < $prev_h) { // higher level
for ($t = 0; $t < $prev_h - $cur_h; $t++) {
$id = mk_contents_truncate_last_ind($id);
}
$id = mk_contents_increment_last_ind($id);
}
if (!$id) { // some error
return $initial_content;
}

// Adds the link to the contents.
$contents .= '<li class="cont' . $cur_h . '"><a href="#' . $id . '">' . $m[3][$i] . '</a></li>' . "\n";

// Adds the 'id' attribute to the header.
/*$content = str_replace(
$m[0][$i],
'<h' . $m[1][$i] . ' id="' . $id . '"' . $m[2][$i] . '>' . $m[3][$i] . '</h',
$content
);*/

// Another approach - with anchors (JLady).
$content = str_replace(
$m[0][$i],
'<p><a name="'. $id . '"></a></p>' . "\n" . $m[0][$i],
$content
);

$prev_h = $cur_h;
}

$content = '<p><b>Содержание статьи:</b></p>' . "\n\n"
. '<ul class="contents">' . "\n" . $contents . '</ul>' . "\n\n"
. $content;

}
}
return $content;
}

add_filter('the_content', 'mk_contents', 10);

?>