


How to call all attached images in a single post in WordPress
How does wordpress call all attached images in a single article
All attachments of an article are identified through the post_parent hook in the POSTS data table, and the post_type is attachment.
After understanding this sentence, check the following code:
/* Get all image attachments under the specified post. */
$attachments = get_children(
array(
'post_parent' => Specify the ID of the log,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID',
'suppress_filters' => true
)
); The next step is foreach to read out the relevant information of the attachment.
How to replace or delete WordPress in bulk
We usually manually insert some of the same text or shortcode into the WordPress article content, because this method is not fixed and is very flexible. For example, different articles often have the same text (some words or phrases), and sometimes I want to replace them with other texts, but there are many articles and it is impossible to modify them one by one; for example, I used to use shortcodes to embed Google The map is very convenient. But later I no longer wanted to use this method, so I removed the corresponding functions that had been placed in functions.php. Unexpectedly, the shortcodes called before were still left in many articles, allowing visitors to see a lot of It’s unsightly. What should I do if it’s time-consuming and laborious to delete the files one by one manually?
This article explains two simple methods. Using only a few simple lines of code, you can easily replace the same text and shortcodes in many articles in batches.
1. Batch replace text content in articles
Add this function to the theme’s functions.php file:
function replace_text_wps($text){
$replace = array(
// 'I am the text to be replaced' =>'I am the text to be replaced'
'wordpress' =>'',
'excerpt' =>'',
'function' =>''
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');
Note: wordpress, excerpt and function in the fourth, fifth and sixth lines of the above code are the texts to be replaced; correspondingly, and are the replaced texts. It is clear that they have been replaced with link text. . The meanings of the last two functions are:
1.add_filter('the_content', 'replace_text_wps'); ——>Replace the text content in the article body
2.add_filter('the_excerpt', 'replace_text_wps'); ——>Replace the text content in the article summary
Via wprecipes
2. Delete or replace the text content in articles in batches (here, we take deleting shortcodes as an example):
There may be many methods, but I think this is the best, which is to execute SQL query statements for batch deletion. It is very thorough, but it involves important data tables of the WordPress database, so you must make a backup of the database in advance.
Log in to the database management center and execute the following statement:
UPDATE wp_posts
SET post_content = REPLACE( post_content, '[adsense]', '' );
Note: What I want to delete here is a shortcode "[adsense]" that is no longer useful. Please modify it to the content you want to delete when using it.
If we want to replace [adsense] with [related_posts], we can write it like this:
UPDATE wp_posts
SET post_content = REPLACE( post_content, '[adsense]', '[related_posts]' );
How does wordpress call articles based on author
wordpress calls the article link, title and content of the specified ID. I found that the method yesterday was not good enough. Today I found a better one. I will try another one later: wordpress calls the page link, title and content of the specified ID.
$post_id = 1; // Post ID, can be found in the WP background
echo get_post( $post_id )->post_content; // Output the content of the article
?>
Here is all the information about the article:
// Calling method:
echo get_post( $post_id )->post_title; // Output the title of the article
// post_author: The number of the author of the article
// post_data: The date and time the article was published (YYYY-MM-DD HH-MM-SS)
// post_data_gmt: Greenwich Mean Time (GMT) when the article was published (YYYY-MM-DD HH-MM-SS)
// post_content: article content
// post_title: article title
// post_category: The number of the article category. Note: This value is always 0 in versions after WordPress 2.1. You can use the get_the_category() function when defining the category of an article.
// post_excerpt: article summary
// post_status: article status (publish|pending|draft|private|static|object|attachment|inherit|future)
// comment_status: comment status (open|closed|registered_only)
// ping_status: pingback/trackback status (open|closed)
// post_password: Post password
// post_name: URL nesting of the article
// to_ping: URL link to be quoted
// pinged: quoted links
// post_modified: The last modified time of the article (YYYY-MM-DD HH-MM-SS)
// post_modified_gmt: The last modified GMT time of the article (YYYY-MM-DD HH-MM-SS)
// post_parent: parent article number (for attachments, etc.)
// guid: A link to the article. Note: You cannot use a GUID as a permanent link (although it was indeed treated as a permanent link in versions prior to 2.5), nor as an available link to an article. A GUID is a unique identifier that currently happens to be a link to an article.
// post_type: (char) (log | page | attachment)
How to use WPAutoPost to collect web pages and automatically update them to wordpress
1. Install WP-AutoPost
You can install WP-AutoPost manually by downloading the ZIP file from your WP-AutoPost.ORG account.
If you want to install WP-AutoPost manually, please follow these steps:
Log in to your WP-AutoPost.ORG account.
Go to the "Account" section.
Download the WP-AutoPost plugin you need (ZIP file).
Upload the downloaded ZIP file to your website's 'wp-contents/plugins' directory.
Extract the ZIP file. This will create a directory.
Log in to your website, go to "Plugins", and enable it.
2. Create tasks and basic settings
Create Task
After clicking "New Task", enter the task name to create a new task. After creating the new task, you can view the task in the task list and make more settings for the task.
basic settings
After clicking "Settings", you can make the following settings under the "Basic Settings Tab":
Task name: Modify task name
Category directory: The category directory where the articles collected by this task are published
Author: The author of the article collected by this task must be a registered user in wordpress
Update interval: How long to check whether there are new articles under this collection task that can be updated
Character set: Collect the character set encoding of the target website. The default is UTF8. If the character set encoding of the target web page is not UTF8, the captured web page will be garbled. This problem can be solved by setting the correct character set (how to set the characters correctly set)
Download remote pictures: If the articles collected under this task contain pictures, you can choose whether to download remote pictures to the local server. If you choose to download remote pictures, you can make the following more settings:
Save the downloaded images to the wordpress media library
Save image to Flickr
Save the image to Qiniu Cloud Storage
Automatically set the first downloaded image as the featured image
Downloaded pictures are automatically added with watermarks, text watermarks or image watermarks can be added
Choose to set the attribute of the image address (if the attribute containing the source image address is not src, you can set it here)
Download remote attachments: If the articles collected under this task contain other types of attachments, you can choose whether to download these attachment files to the local server. After selecting the download, you can make the following more settings:
Save the downloaded attachment information to the wordpress media library
Auto tag: Choose whether to use automatic tags
Tag list: After using automatic tags, if the article contains the keywords in the list, tags
will be added automatically.Match complete words: This setting is valid for English articles, please do not enable this setting for Chinese articles
Automatic summary: The first paragraph or the first few paragraphs of text in the article can be automatically set as the summary
Publication status: Collect the status of the article after publication, which can be: published, draft, waiting for review
Manual selective collection: Select Yes to manually select which articles can be collected and published
3. Article source settings
Article Source Settings
Under this tab we need to set the article list URL of the article source and the matching rules for specific articles
The above is the detailed content of How to call all attached images in a single post in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Excel web version features enhancements to improve efficiency! While Excel desktop version is more powerful, the web version has also been significantly improved over the past year. This article will focus on five key improvements: Easily insert rows and columns: In Excel web, just hover over the row or column header and click the " " sign that appears to insert a new row or column. There is no need to use the confusing right-click menu "insert" function anymore. This method is faster, and newly inserted rows or columns inherit the format of adjacent cells. Export as CSV files: Excel now supports exporting worksheets as CSV files for easy data transfer and compatibility with other software. Click "File" > "Export"

Excel's LAMBDA Functions: An easy guide to creating custom functions Before Excel introduced the LAMBDA function, creating a custom function requires VBA or macro. Now, with LAMBDA, you can easily implement it using the familiar Excel syntax. This guide will guide you step by step how to use the LAMBDA function. It is recommended that you read the parts of this guide in order, first understand the grammar and simple examples, and then learn practical applications. The LAMBDA function is available for Microsoft 365 (Windows and Mac), Excel 2024 (Windows and Mac), and Excel for the web. E

In Excel, using the timeline filter can display data by time period more efficiently, which is more convenient than using the filter button. The Timeline is a dynamic filtering option that allows you to quickly display data for a single date, month, quarter, or year. Step 1: Convert data to pivot table First, convert the original Excel data into a pivot table. Select any cell in the data table (formatted or not) and click PivotTable on the Insert tab of the ribbon. Related: How to Create Pivot Tables in Microsoft Excel Don't be intimidated by the pivot table! We will teach you basic skills that you can master in minutes. Related Articles In the dialog box, make sure the entire data range is selected (

Quick Links Why Use the Camera Tool?

Excel's PERCENTOF function: Easily calculate the proportion of data subsets Excel's PERCENTOF function can quickly calculate the proportion of data subsets in the entire data set, avoiding the hassle of creating complex formulas. PERCENTOF function syntax The PERCENTOF function has two parameters: =PERCENTOF(a,b) in: a (required) is a subset of data that forms part of the entire data set; b (required) is the entire dataset. In other words, the PERCENTOF function calculates the percentage of the subset a to the total dataset b. Calculate the proportion of individual values using PERCENTOF The easiest way to use the PERCENTOF function is to calculate the single

Excel Overflow Range Operator (#) enables formulas to be automatically adjusted to accommodate changes in overflow range size. This feature is only available for Microsoft 365 Excel for Windows or Mac. Common functions such as UNIQUE, COUNTIF, and SORTBY can be used in conjunction with overflow range operators to generate dynamic sortable lists. The pound sign (#) in the Excel formula is also called the overflow range operator, which instructs the program to consider all results in the overflow range. Therefore, even if the overflow range increases or decreases, the formula containing # will automatically reflect this change. How to list and sort unique values in Microsoft Excel

Use formula conditional formatting to handle overflow arrays in Excel Direct formatting of overflow arrays in Excel can cause problems, especially when the data shape or size changes. Formula-based conditional formatting rules allow automatic formatting to be adjusted when data parameters change. Adding a dollar sign ($) before a column reference applies a rule to all rows in the data. In Excel, you can apply direct formatting to the values or background of a cell to make the spreadsheet easier to read. However, when an Excel formula returns a set of values (called overflow arrays), applying direct formatting will cause problems if the size or shape of the data changes. Suppose you have this spreadsheet with overflow results from the PIVOTBY formula,
